Update to use geanyfunctions.h.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3317 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2008-12-04 17:05:36 +00:00
parent 724ac63ac1
commit 73d44c0a79
8 changed files with 245 additions and 241 deletions

View File

@ -22,6 +22,10 @@
Allow generating macros for functions with digits in the name.
Don't generate dummyprefix_scintilla_send_message and lookup_widget
macros.
* plugins/saveactions.c, plugins/export.c, plugins/vcdiff.c,
plugins/filebrowser.c, plugins/splitwindow.c, plugins/htmlchars.c,
plugins/classbuilder.c:
Update to use geanyfunctions.h.
2008-12-03 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>

View File

@ -32,7 +32,7 @@
#include "document.h"
#include "editor.h"
#include "ui_utils.h"
#include "pluginmacros.h"
#include "geanyfunctions.h"
GeanyData *geany_data;
@ -253,30 +253,30 @@ get_template_class_header(ClassInfo *class_info)
switch (class_info->type)
{
case GEANY_CLASS_TYPE_CPP:
fileheader = p_templates->get_template_fileheader(GEANY_FILETYPES_CPP, class_info->header);
fileheader = templates_get_template_fileheader(GEANY_FILETYPES_CPP, class_info->header);
template = g_string_new(templates_cpp_class_header);
p_utils->string_replace_all(template, "{fileheader}", fileheader);
p_utils->string_replace_all(template, "{header_guard}", class_info->header_guard);
p_utils->string_replace_all(template, "{base_include}", class_info->base_include);
p_utils->string_replace_all(template, "{class_name}", class_info->class_name);
p_utils->string_replace_all(template, "{base_decl}", class_info->base_decl);
p_utils->string_replace_all(template, "{constructor_decl}",
utils_string_replace_all(template, "{fileheader}", fileheader);
utils_string_replace_all(template, "{header_guard}", class_info->header_guard);
utils_string_replace_all(template, "{base_include}", class_info->base_include);
utils_string_replace_all(template, "{class_name}", class_info->class_name);
utils_string_replace_all(template, "{base_decl}", class_info->base_decl);
utils_string_replace_all(template, "{constructor_decl}",
class_info->constructor_decl);
p_utils->string_replace_all(template, "{destructor_decl}",
utils_string_replace_all(template, "{destructor_decl}",
class_info->destructor_decl);
break;
case GEANY_CLASS_TYPE_GTK:
fileheader = p_templates->get_template_fileheader(GEANY_FILETYPES_C, class_info->header);
fileheader = templates_get_template_fileheader(GEANY_FILETYPES_C, class_info->header);
template = g_string_new(templates_gtk_class_header);
p_utils->string_replace_all(template, "{fileheader}", fileheader);
p_utils->string_replace_all(template, "{header_guard}", class_info->header_guard);
p_utils->string_replace_all(template, "{base_include}", class_info->base_include);
p_utils->string_replace_all(template, "{class_name}", class_info->class_name);
p_utils->string_replace_all(template, "{class_name_up}", class_info->class_name_up);
p_utils->string_replace_all(template, "{class_name_low}", class_info->class_name_low);
p_utils->string_replace_all(template, "{base_name}", class_info->base_name);
p_utils->string_replace_all(template, "{constructor_decl}",
utils_string_replace_all(template, "{fileheader}", fileheader);
utils_string_replace_all(template, "{header_guard}", class_info->header_guard);
utils_string_replace_all(template, "{base_include}", class_info->base_include);
utils_string_replace_all(template, "{class_name}", class_info->class_name);
utils_string_replace_all(template, "{class_name_up}", class_info->class_name_up);
utils_string_replace_all(template, "{class_name_low}", class_info->class_name_low);
utils_string_replace_all(template, "{base_name}", class_info->base_name);
utils_string_replace_all(template, "{constructor_decl}",
class_info->constructor_decl);
break;
}
@ -299,35 +299,35 @@ get_template_class_source(ClassInfo *class_info)
switch (class_info->type)
{
case GEANY_CLASS_TYPE_CPP:
fileheader = p_templates->get_template_fileheader(GEANY_FILETYPES_CPP, class_info->source);
fileheader = templates_get_template_fileheader(GEANY_FILETYPES_CPP, class_info->source);
template = g_string_new(templates_cpp_class_source);
p_utils->string_replace_all(template, "{fileheader}", fileheader);
p_utils->string_replace_all(template, "{header}", class_info->header);
p_utils->string_replace_all(template, "{class_name}", class_info->class_name);
p_utils->string_replace_all(template, "{base_include}", class_info->base_include);
p_utils->string_replace_all(template, "{base_name}", class_info->base_name);
p_utils->string_replace_all(template, "{constructor_impl}",
utils_string_replace_all(template, "{fileheader}", fileheader);
utils_string_replace_all(template, "{header}", class_info->header);
utils_string_replace_all(template, "{class_name}", class_info->class_name);
utils_string_replace_all(template, "{base_include}", class_info->base_include);
utils_string_replace_all(template, "{base_name}", class_info->base_name);
utils_string_replace_all(template, "{constructor_impl}",
class_info->constructor_impl);
p_utils->string_replace_all(template, "{destructor_impl}",
utils_string_replace_all(template, "{destructor_impl}",
class_info->destructor_impl);
break;
case GEANY_CLASS_TYPE_GTK:
fileheader = p_templates->get_template_fileheader(GEANY_FILETYPES_C, class_info->source);
fileheader = templates_get_template_fileheader(GEANY_FILETYPES_C, class_info->source);
template = g_string_new(templates_gtk_class_source);
p_utils->string_replace_all(template, "{fileheader}", fileheader);
p_utils->string_replace_all(template, "{header}", class_info->header);
p_utils->string_replace_all(template, "{class_name}", class_info->class_name);
p_utils->string_replace_all(template, "{class_name_up}", class_info->class_name_up);
p_utils->string_replace_all(template, "{class_name_low}", class_info->class_name_low);
p_utils->string_replace_all(template, "{base_name}", class_info->base_name);
p_utils->string_replace_all(template, "{base_gtype}", class_info->base_gtype);
p_utils->string_replace_all(template, "{destructor_decl}", class_info->destructor_decl);
p_utils->string_replace_all(template, "{constructor_impl}",
utils_string_replace_all(template, "{fileheader}", fileheader);
utils_string_replace_all(template, "{header}", class_info->header);
utils_string_replace_all(template, "{class_name}", class_info->class_name);
utils_string_replace_all(template, "{class_name_up}", class_info->class_name_up);
utils_string_replace_all(template, "{class_name_low}", class_info->class_name_low);
utils_string_replace_all(template, "{base_name}", class_info->base_name);
utils_string_replace_all(template, "{base_gtype}", class_info->base_gtype);
utils_string_replace_all(template, "{destructor_decl}", class_info->destructor_decl);
utils_string_replace_all(template, "{constructor_impl}",
class_info->constructor_impl);
p_utils->string_replace_all(template, "{destructor_impl}",
utils_string_replace_all(template, "{destructor_impl}",
class_info->destructor_impl);
p_utils->string_replace_all(template, "{gtk_destructor_registration}",
utils_string_replace_all(template, "{gtk_destructor_registration}",
class_info->gtk_destructor_registration);
break;
}
@ -362,9 +362,9 @@ void show_dialog_create_class(gint type)
NULL);
g_signal_connect_swapped(cc_dlg->dialog, "destroy", G_CALLBACK(g_free), (gpointer)cc_dlg);
main_box = p_ui->dialog_vbox_new(GTK_DIALOG(cc_dlg->dialog));
main_box = ui_dialog_vbox_new(GTK_DIALOG(cc_dlg->dialog));
frame = p_ui->frame_new_with_alignment(_("Class"), &align);
frame = ui_frame_new_with_alignment(_("Class"), &align);
gtk_container_add(GTK_CONTAINER(main_box), frame);
vbox = gtk_vbox_new(FALSE, 10);
@ -399,7 +399,7 @@ void show_dialog_create_class(gint type)
cc_dlg->source_entry = gtk_entry_new();
gtk_container_add(GTK_CONTAINER(hbox), cc_dlg->source_entry);
frame = p_ui->frame_new_with_alignment(_("Inheritance"), &align);
frame = ui_frame_new_with_alignment(_("Inheritance"), &align);
gtk_container_add(GTK_CONTAINER(main_box), frame);
vbox = gtk_vbox_new(FALSE, 10);
@ -446,7 +446,7 @@ void show_dialog_create_class(gint type)
gtk_container_add(GTK_CONTAINER(hbox), cc_dlg->base_gtype_entry);
}
frame = p_ui->frame_new_with_alignment(_("Options"), &align);
frame = ui_frame_new_with_alignment(_("Options"), &align);
gtk_container_add(GTK_CONTAINER(main_box), frame);
vbox = gtk_vbox_new(FALSE, 10);
@ -559,7 +559,7 @@ static void cc_dlg_on_base_name_entry_changed(GtkWidget *entry, CreateClassDialo
/*tmp = g_strconcat("gtk/", gtk_entry_get_text(GTK_ENTRY(entry)), ".h", NULL);*/
/* With GTK 2.14 (and later GTK 3), single header includes are encouraged */
tmp = g_strdup("gtk/gtk.h");
else if (p_utils->str_equal(gtk_entry_get_text(GTK_ENTRY(entry)), "GObject"))
else if (utils_str_equal(gtk_entry_get_text(GTK_ENTRY(entry)), "GObject"))
tmp = g_strdup("glib-object.h");
else
tmp = g_strconcat(gtk_entry_get_text(GTK_ENTRY(entry)), ".h", NULL);
@ -575,7 +575,7 @@ static void cc_dlg_on_base_name_entry_changed(GtkWidget *entry, CreateClassDialo
tmp = g_strdup_printf("%.3s_TYPE%s",
base_name_splitted,
base_name_splitted + 3);
else if (p_utils->str_equal(gtk_entry_get_text(GTK_ENTRY(entry)), "GObject"))
else if (utils_str_equal(gtk_entry_get_text(GTK_ENTRY(entry)), "GObject"))
tmp = g_strdup("G_TYPE_OBJECT");
else
tmp = g_strconcat(base_name_splitted, "_TYPE", NULL);
@ -600,7 +600,7 @@ static void cc_dlg_on_create_class(CreateClassDialog *cc_dlg)
g_return_if_fail(cc_dlg != NULL);
if (p_utils->str_equal(gtk_entry_get_text(GTK_ENTRY(cc_dlg->class_name_entry)), ""))
if (utils_str_equal(gtk_entry_get_text(GTK_ENTRY(cc_dlg->class_name_entry)), ""))
return;
class_info = g_new0(ClassInfo, 1);
@ -609,7 +609,7 @@ static void cc_dlg_on_create_class(CreateClassDialog *cc_dlg)
tmp = str_case_split(class_info->class_name, '_');
class_info->class_name_up = g_ascii_strup(tmp, -1);
class_info->class_name_low = g_ascii_strdown(class_info->class_name_up, -1);
if (! p_utils->str_equal(gtk_entry_get_text(GTK_ENTRY(cc_dlg->base_name_entry)), ""))
if (! utils_str_equal(gtk_entry_get_text(GTK_ENTRY(cc_dlg->base_name_entry)), ""))
{
class_info->base_name = g_strdup(gtk_entry_get_text(GTK_ENTRY(cc_dlg->base_name_entry)));
class_info->base_include = g_strdup_printf("\n#include %c%s%c\n",
@ -632,7 +632,7 @@ static void cc_dlg_on_create_class(CreateClassDialog *cc_dlg)
case GEANY_CLASS_TYPE_CPP:
{
class_info->source = g_strdup(gtk_entry_get_text(GTK_ENTRY(cc_dlg->source_entry)));
if (! p_utils->str_equal(class_info->base_name, ""))
if (! utils_str_equal(class_info->base_name, ""))
class_info->base_decl = g_strdup_printf(": public %s", class_info->base_name);
else
class_info->base_decl = g_strdup("");
@ -640,7 +640,7 @@ static void cc_dlg_on_create_class(CreateClassDialog *cc_dlg)
{
gchar *base_constructor;
if (p_utils->str_equal(class_info->base_name, ""))
if (utils_str_equal(class_info->base_name, ""))
base_constructor = g_strdup("");
else
base_constructor = g_strdup_printf("\t: %s()\n", class_info->base_name);
@ -729,19 +729,19 @@ static void cc_dlg_on_create_class(CreateClassDialog *cc_dlg)
}
/* only create the files if the filename is not empty */
if (! p_utils->str_equal(class_info->source, ""))
if (! utils_str_equal(class_info->source, ""))
{
text = get_template_class_source(class_info);
doc = p_document->new_file(class_info->source, NULL, NULL);
p_sci->set_text(doc->editor->sci, text);
doc = document_new_file(class_info->source, NULL, NULL);
sci_set_text(doc->editor->sci, text);
g_free(text);
}
if (! p_utils->str_equal(class_info->header, ""))
if (! utils_str_equal(class_info->header, ""))
{
text = get_template_class_header(class_info);
doc = p_document->new_file(class_info->header, NULL, NULL);
p_sci->set_text(doc->editor->sci, text);
doc = document_new_file(class_info->header, NULL, NULL);
sci_set_text(doc->editor->sci, text);
g_free(text);
}
@ -777,7 +777,7 @@ void plugin_init(GeanyData *data)
GtkWidget *menu_create_cpp_class;
GtkWidget *menu_create_gtk_class;
menu_create_class1 = p_ui->image_menu_item_new (GTK_STOCK_ADD, _("Create Cla_ss"));
menu_create_class1 = ui_image_menu_item_new (GTK_STOCK_ADD, _("Create Cla_ss"));
gtk_container_add (GTK_CONTAINER (geany->main_widgets->tools_menu), menu_create_class1);
menu_create_class1_menu = gtk_menu_new ();
@ -798,7 +798,7 @@ void plugin_init(GeanyData *data)
gtk_widget_show_all(menu_create_class1);
p_ui->add_document_sensitive(menu_create_class1);
ui_add_document_sensitive(menu_create_class1);
main_menu_item = menu_create_class1;
}

View File

@ -35,7 +35,7 @@
#include "prefs.h"
#include "utils.h"
#include "ui_utils.h"
#include "pluginmacros.h"
#include "geanyfunctions.h"
GeanyData *geany_data;
@ -164,7 +164,7 @@ static void create_file_save_as_dialog(const gchar *extension, ExportFunc func,
if (extension == NULL)
return;
doc = p_document->get_current();
doc = document_get_current();
exi = g_new(ExportInfo, 1);
exi->doc = doc;
@ -189,7 +189,7 @@ static void create_file_save_as_dialog(const gchar *extension, ExportFunc func,
vbox = gtk_vbox_new(FALSE, 0);
check_zoom_level = gtk_check_button_new_with_mnemonic(_("_Use current zoom level"));
p_ui->widget_set_tooltip_text(check_zoom_level,
ui_widget_set_tooltip_text(check_zoom_level,
_("Renders the font size of the document together with the current zoom level."));
gtk_box_pack_start(GTK_BOX(vbox), check_zoom_level, FALSE, FALSE, 0);
gtk_widget_show_all(vbox);
@ -211,7 +211,7 @@ static void create_file_save_as_dialog(const gchar *extension, ExportFunc func,
if (doc->file_name != NULL)
{
gchar *base_name = g_path_get_basename(doc->file_name);
gchar *short_name = p_utils->remove_ext_from_filename(base_name);
gchar *short_name = utils_remove_ext_from_filename(base_name);
gchar *file_name;
gchar *locale_filename;
gchar *locale_dirname;
@ -221,7 +221,7 @@ static void create_file_save_as_dialog(const gchar *extension, ExportFunc func,
suffix = "_export";
file_name = g_strconcat(short_name, suffix, extension, NULL);
locale_filename = p_utils->get_locale_from_utf8(doc->file_name);
locale_filename = utils_get_locale_from_utf8(doc->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
@ -244,7 +244,7 @@ static void create_file_save_as_dialog(const gchar *extension, ExportFunc func,
/* use default startup directory(if set) if no files are open */
if (NZV(default_open_path) && g_path_is_absolute(default_open_path))
{
gchar *locale_path = p_utils->get_locale_from_utf8(default_open_path);
gchar *locale_path = utils_get_locale_from_utf8(default_open_path);
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), locale_path);
g_free(locale_path);
}
@ -268,13 +268,13 @@ static void on_menu_create_html_activate(GtkMenuItem *menuitem, gpointer user_da
static void write_data(const gchar *filename, const gchar *data)
{
gint error_nr = p_utils->write_file(filename, data);
gchar *utf8_filename = p_utils->get_utf8_from_locale(filename);
gint error_nr = utils_write_file(filename, data);
gchar *utf8_filename = utils_get_utf8_from_locale(filename);
if (error_nr == 0)
p_ui->set_statusbar(TRUE, _("Document successfully exported as '%s'."), utf8_filename);
ui_set_statusbar(TRUE, _("Document successfully exported as '%s'."), utf8_filename);
else
p_ui->set_statusbar(TRUE, _("File '%s' could not be written (%s)."),
ui_set_statusbar(TRUE, _("File '%s' could not be written (%s)."),
utf8_filename, g_strerror(error_nr));
g_free(utf8_filename);
@ -295,7 +295,7 @@ static gchar *get_date(gint type)
else
format = "%c";
return p_utils->get_date_time(format, NULL);
return utils_get_date_time(format, NULL);
}
@ -312,15 +312,15 @@ static void on_file_save_dialog_response(GtkDialog *dialog, gint response, gpoin
if (exi->have_zoom_level_checkbox)
{
use_zoom_level = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
p_support->lookup_widget(GTK_WIDGET(dialog), "check_zoom_level")));
ui_lookup_widget(GTK_WIDGET(dialog), "check_zoom_level")));
}
utf8_filename = p_utils->get_utf8_from_locale(new_filename);
utf8_filename = utils_get_utf8_from_locale(new_filename);
/* check if file exists and ask whether to overwrite or not */
if (g_file_test(new_filename, G_FILE_TEST_EXISTS))
{
if (p_dialogs->show_question(
if (dialogs_show_question(
_("The file '%s' already exists. Do you want to overwrite it?"),
utf8_filename) == FALSE)
return;
@ -347,25 +347,25 @@ static void write_latex_file(GeanyDocument *doc, const gchar *filename, gboolean
GString *body;
GString *cmds;
GString *latex;
gint style_max = pow(2, p_sci->send_message(doc->editor->sci, SCI_GETSTYLEBITS, 0, 0));
gint style_max = pow(2, scintilla_send_message(doc->editor->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->editor->sci, SCI_STYLEGETFORE, i, 0);
styles[i][BACK] = p_sci->send_message(doc->editor->sci, SCI_STYLEGETBACK, i, 0);
styles[i][BOLD] = p_sci->send_message(doc->editor->sci, SCI_STYLEGETBOLD, i, 0);
styles[i][ITALIC] = p_sci->send_message(doc->editor->sci, SCI_STYLEGETITALIC, i, 0);
styles[i][FORE] = scintilla_send_message(doc->editor->sci, SCI_STYLEGETFORE, i, 0);
styles[i][BACK] = scintilla_send_message(doc->editor->sci, SCI_STYLEGETBACK, i, 0);
styles[i][BOLD] = scintilla_send_message(doc->editor->sci, SCI_STYLEGETBOLD, i, 0);
styles[i][ITALIC] = scintilla_send_message(doc->editor->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->editor->sci); i++)
for (i = 0; i < sci_get_length(doc->editor->sci); i++)
{
style = p_sci->get_style_at(doc->editor->sci, i);
c = p_sci->get_char_at(doc->editor->sci, i);
c_next = p_sci->get_char_at(doc->editor->sci, i + 1);
style = sci_get_style_at(doc->editor->sci, i);
c = sci_get_char_at(doc->editor->sci, i);
c_next = sci_get_char_at(doc->editor->sci, i + 1);
if (style != old_style || ! block_open)
{
@ -400,7 +400,7 @@ static void write_latex_file(GeanyDocument *doc, const gchar *filename, gboolean
}
case '\t':
{
gint tab_width = p_sci->get_tab_width(editor->sci);
gint tab_width = sci_get_tab_width(editor->sci);
gint tab_stop = tab_width - (column % tab_width);
column += tab_stop - 1; /* -1 because we add 1 at the end of the loop */
@ -526,13 +526,13 @@ static void write_latex_file(GeanyDocument *doc, const gchar *filename, gboolean
date = get_date(DATE_TYPE_DEFAULT);
/* write all */
latex = g_string_new(TEMPLATE_LATEX);
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}", date);
utils_string_replace_all(latex, "{export_content}", body->str);
utils_string_replace_all(latex, "{export_styles}", cmds->str);
utils_string_replace_all(latex, "{export_date}", date);
if (doc->file_name == NULL)
p_utils->string_replace_all(latex, "{export_filename}", GEANY_STRING_UNTITLED);
utils_string_replace_all(latex, "{export_filename}", GEANY_STRING_UNTITLED);
else
p_utils->string_replace_all(latex, "{export_filename}", doc->file_name);
utils_string_replace_all(latex, "{export_filename}", doc->file_name);
write_data(filename, latex->str);
@ -557,15 +557,15 @@ static void write_html_file(GeanyDocument *doc, const gchar *filename, gboolean
GString *body;
GString *css;
GString *html;
gint style_max = pow(2, p_sci->send_message(doc->editor->sci, SCI_GETSTYLEBITS, 0, 0));
gint style_max = pow(2, scintilla_send_message(doc->editor->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->editor->sci, SCI_STYLEGETFORE, i, 0));
styles[i][BACK] = ROTATE_RGB(p_sci->send_message(doc->editor->sci, SCI_STYLEGETBACK, i, 0));
styles[i][BOLD] = p_sci->send_message(doc->editor->sci, SCI_STYLEGETBOLD, i, 0);
styles[i][ITALIC] = p_sci->send_message(doc->editor->sci, SCI_STYLEGETITALIC, i, 0);
styles[i][FORE] = ROTATE_RGB(scintilla_send_message(doc->editor->sci, SCI_STYLEGETFORE, i, 0));
styles[i][BACK] = ROTATE_RGB(scintilla_send_message(doc->editor->sci, SCI_STYLEGETBACK, i, 0));
styles[i][BOLD] = scintilla_send_message(doc->editor->sci, SCI_STYLEGETBOLD, i, 0);
styles[i][ITALIC] = scintilla_send_message(doc->editor->sci, SCI_STYLEGETITALIC, i, 0);
styles[i][USED] = 0;
}
@ -574,18 +574,18 @@ static void write_html_file(GeanyDocument *doc, const gchar *filename, gboolean
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->editor->sci, SCI_STYLEGETSIZE, 0, 0);
font_size = scintilla_send_message(doc->editor->sci, SCI_STYLEGETSIZE, 0, 0);
if (use_zoom)
font_size += p_sci->send_message(doc->editor->sci, SCI_GETZOOM, 0, 0);
font_size += scintilla_send_message(doc->editor->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->editor->sci); i++)
for (i = 0; i < sci_get_length(doc->editor->sci); i++)
{
style = p_sci->get_style_at(doc->editor->sci, i);
c = p_sci->get_char_at(doc->editor->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->editor->sci, i + 1);
style = sci_get_style_at(doc->editor->sci, i);
c = sci_get_char_at(doc->editor->sci, i);
/* sci_get_char_at() takes care of index boundaries and return 0 if i is too high */
c_next = sci_get_char_at(doc->editor->sci, i + 1);
if ((style != old_style || ! span_open) && ! isspace(c))
{
@ -620,7 +620,7 @@ static void write_html_file(GeanyDocument *doc, const gchar *filename, gboolean
case '\t':
{
gint j;
gint tab_width = p_sci->get_tab_width(editor->sci);
gint tab_width = sci_get_tab_width(editor->sci);
gint tab_stop = tab_width - (column % tab_width);
column += tab_stop - 1; /* -1 because we add 1 at the end of the loop */
@ -681,13 +681,13 @@ static void write_html_file(GeanyDocument *doc, const gchar *filename, gboolean
date = get_date(DATE_TYPE_HTML);
/* write all */
html = g_string_new(TEMPLATE_HTML);
p_utils->string_replace_all(html, "{export_date}", date);
p_utils->string_replace_all(html, "{export_content}", body->str);
p_utils->string_replace_all(html, "{export_styles}", css->str);
utils_string_replace_all(html, "{export_date}", date);
utils_string_replace_all(html, "{export_content}", body->str);
utils_string_replace_all(html, "{export_styles}", css->str);
if (doc->file_name == NULL)
p_utils->string_replace_all(html, "{export_filename}", GEANY_STRING_UNTITLED);
utils_string_replace_all(html, "{export_filename}", GEANY_STRING_UNTITLED);
else
p_utils->string_replace_all(html, "{export_filename}", doc->file_name);
utils_string_replace_all(html, "{export_filename}", doc->file_name);
write_data(filename, html->str);
@ -726,7 +726,7 @@ void plugin_init(GeanyData *data)
G_CALLBACK(on_menu_create_latex_activate), NULL);
/* disable menu_item when there are no documents open */
p_ui->add_document_sensitive(menu_export);
ui_add_document_sensitive(menu_export);
main_menu_item = menu_export;
gtk_widget_show_all(menu_export);

View File

@ -38,7 +38,7 @@
#include "ui_utils.h"
#include "plugindata.h"
#include "pluginmacros.h"
#include "geanyfunctions.h"
GeanyData *geany_data;
@ -131,7 +131,7 @@ static gboolean check_filtered(const gchar *base_name)
if (filter == NULL)
return FALSE;
if (! p_utils->str_equal(base_name, "*") && ! g_pattern_match_simple(filter, base_name))
if (! utils_str_equal(base_name, "*") && ! g_pattern_match_simple(filter, base_name))
{
return TRUE;
}
@ -171,7 +171,7 @@ static void add_item(const gchar *name)
else
gtk_list_store_append(file_store, &iter);
utf8_name = p_utils->get_utf8_from_locale(name);
utf8_name = utils_get_utf8_from_locale(name);
gtk_list_store_set(file_store, &iter,
FILEVIEW_COLUMN_ICON, (dir) ? GTK_STOCK_DIRECTORY : GTK_STOCK_FILE,
@ -219,13 +219,13 @@ static void refresh(void)
clear();
utf8_dir = p_utils->get_utf8_from_locale(current_dir);
utf8_dir = utils_get_utf8_from_locale(current_dir);
gtk_entry_set_text(GTK_ENTRY(path_entry), utf8_dir);
g_free(utf8_dir);
add_top_level_entry(); /* ".." item */
list = p_utils->get_file_list(current_dir, NULL, NULL);
list = utils_get_file_list(current_dir, NULL, NULL);
if (list != NULL)
{
g_slist_foreach(list, (GFunc) add_item, NULL);
@ -251,7 +251,7 @@ static gchar *get_default_dir(void)
if (project)
dir = project->base_path;
if (NZV(dir))
return p_utils->get_locale_from_utf8(dir);
return utils_get_locale_from_utf8(dir);
return g_get_current_dir();
}
@ -261,7 +261,7 @@ static void on_current_path(void)
{
gchar *fname;
gchar *dir;
GeanyDocument *doc = p_document->get_current();
GeanyDocument *doc = document_get_current();
if (doc == NULL || doc->file_name == NULL || ! g_path_is_absolute(doc->file_name))
{
@ -270,7 +270,7 @@ static void on_current_path(void)
return;
}
fname = doc->file_name;
fname = p_utils->get_locale_from_utf8(fname);
fname = utils_get_locale_from_utf8(fname);
dir = g_path_get_dirname(fname);
g_free(fname);
@ -292,7 +292,7 @@ static gboolean check_single_selection(GtkTreeSelection *treesel)
if (gtk_tree_selection_count_selected_rows(treesel) == 1)
return TRUE;
p_ui->set_statusbar(FALSE, _("Too many items selected!"));
ui_set_statusbar(FALSE, _("Too many items selected!"));
return FALSE;
}
@ -314,7 +314,7 @@ static gboolean is_folder_selected(GList *selected_items)
gtk_tree_model_get_iter(model, &iter, treepath);
gtk_tree_model_get(model, &iter, FILEVIEW_COLUMN_ICON, &icon, -1);
if (p_utils->str_equal(icon, GTK_STOCK_DIRECTORY))
if (utils_str_equal(icon, GTK_STOCK_DIRECTORY))
{
dir_found = TRUE;
g_free(icon);
@ -336,13 +336,13 @@ static gchar *get_tree_path_filename(GtkTreePath *treepath)
gtk_tree_model_get_iter(model, &iter, treepath);
gtk_tree_model_get(model, &iter, FILEVIEW_COLUMN_NAME, &name, -1);
if (p_utils->str_equal(name, ".."))
if (utils_str_equal(name, ".."))
{
fname = g_path_get_dirname(current_dir);
}
else
{
setptr(name, p_utils->get_locale_from_utf8(name));
setptr(name, utils_get_locale_from_utf8(name));
fname = g_build_filename(current_dir, name, NULL);
}
g_free(name);
@ -364,18 +364,18 @@ static void open_external(const gchar *fname, gboolean dir_found)
else
dir = g_strdup(fname);
p_utils->string_replace_all(cmd_str, "%f", fname);
p_utils->string_replace_all(cmd_str, "%d", dir);
utils_string_replace_all(cmd_str, "%f", fname);
utils_string_replace_all(cmd_str, "%d", dir);
cmd = g_string_free(cmd_str, FALSE);
locale_cmd = p_utils->get_locale_from_utf8(cmd);
locale_cmd = utils_get_locale_from_utf8(cmd);
if (! g_spawn_command_line_async(locale_cmd, &error))
{
gchar *c = strchr(cmd, ' ');
if (c != NULL)
*c = '\0';
p_ui->set_statusbar(TRUE,
ui_set_statusbar(TRUE,
_("Could not execute configured external command '%s' (%s)."),
cmd, error->message);
g_error_free(error);
@ -417,7 +417,7 @@ static void on_external_open(GtkMenuItem *menuitem, gpointer user_data)
}
/* We use p_document->open_files() as it's more efficient. */
/* We use document_open_files() as it's more efficient. */
static void open_selected_files(GList *list)
{
GSList *files = NULL;
@ -430,7 +430,7 @@ static void open_selected_files(GList *list)
files = g_slist_append(files, fname);
}
p_document->open_files(files, FALSE, NULL, NULL);
document_open_files(files, FALSE, NULL, NULL);
g_slist_foreach(files, (GFunc) g_free, NULL); /* free filenames */
g_slist_free(files);
}
@ -501,8 +501,8 @@ static void on_find_in_files(GtkMenuItem *menuitem, gpointer user_data)
g_list_foreach(list, (GFunc) gtk_tree_path_free, NULL);
g_list_free(list);
setptr(dir, p_utils->get_utf8_from_locale(dir));
p_search->show_find_in_files_dialog(dir);
setptr(dir, utils_get_utf8_from_locale(dir));
search_show_find_in_files_dialog(dir);
g_free(dir);
}
@ -516,7 +516,7 @@ static void on_hidden_files_clicked(GtkCheckMenuItem *item)
static void on_hide_sidebar(void)
{
p_keybindings->send_command(GEANY_KEY_GROUP_VIEW, GEANY_KEYS_VIEW_SIDEBAR);
keybindings_send_command(GEANY_KEY_GROUP_VIEW, GEANY_KEYS_VIEW_SIDEBAR);
}
@ -532,13 +532,13 @@ static GtkWidget *create_popup_menu(void)
g_signal_connect(item, "activate", G_CALLBACK(on_open_clicked), NULL);
popup_items.open = item;
item = p_ui->image_menu_item_new(GTK_STOCK_OPEN, _("Open _externally"));
item = ui_image_menu_item_new(GTK_STOCK_OPEN, _("Open _externally"));
gtk_widget_show(item);
gtk_container_add(GTK_CONTAINER(menu), item);
g_signal_connect(item, "activate", G_CALLBACK(on_external_open), NULL);
popup_items.open_external = item;
item = p_ui->image_menu_item_new(GTK_STOCK_FIND, _("_Find in Files"));
item = ui_image_menu_item_new(GTK_STOCK_FIND, _("_Find in Files"));
gtk_widget_show(item);
gtk_container_add(GTK_CONTAINER(menu), item);
g_signal_connect(item, "activate", G_CALLBACK(on_find_in_files), NULL);
@ -557,7 +557,7 @@ static GtkWidget *create_popup_menu(void)
gtk_widget_show(item);
gtk_container_add(GTK_CONTAINER(menu), item);
item = p_ui->image_menu_item_new(GTK_STOCK_CLOSE, _("H_ide Sidebar"));
item = ui_image_menu_item_new(GTK_STOCK_CLOSE, _("H_ide Sidebar"));
gtk_widget_show(item);
gtk_container_add(GTK_CONTAINER(menu), item);
g_signal_connect(item, "activate", G_CALLBACK(on_hide_sidebar), NULL);
@ -644,7 +644,7 @@ static void on_path_entry_activate(GtkEntry *entry, gpointer user_data)
on_go_up();
return;
}
new_dir = p_utils->get_locale_from_utf8(new_dir);
new_dir = utils_get_locale_from_utf8(new_dir);
}
else
new_dir = g_strdup(g_get_home_dir());
@ -717,22 +717,22 @@ static GtkWidget *make_toolbar(void)
gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);
wid = (GtkWidget *) gtk_tool_button_new_from_stock(GTK_STOCK_GO_UP);
p_ui->widget_set_tooltip_text(wid, _("Up"));
ui_widget_set_tooltip_text(wid, _("Up"));
g_signal_connect(wid, "clicked", G_CALLBACK(on_go_up), NULL);
gtk_container_add(GTK_CONTAINER(toolbar), wid);
wid = (GtkWidget *) gtk_tool_button_new_from_stock(GTK_STOCK_REFRESH);
p_ui->widget_set_tooltip_text(wid, _("Refresh"));
ui_widget_set_tooltip_text(wid, _("Refresh"));
g_signal_connect(wid, "clicked", G_CALLBACK(refresh), NULL);
gtk_container_add(GTK_CONTAINER(toolbar), wid);
wid = (GtkWidget *) gtk_tool_button_new_from_stock(GTK_STOCK_HOME);
p_ui->widget_set_tooltip_text(wid, _("Home"));
ui_widget_set_tooltip_text(wid, _("Home"));
g_signal_connect(wid, "clicked", G_CALLBACK(on_go_home), NULL);
gtk_container_add(GTK_CONTAINER(toolbar), wid);
wid = (GtkWidget *) gtk_tool_button_new_from_stock(GTK_STOCK_JUMP_TO);
p_ui->widget_set_tooltip_text(wid, _("Set path from document"));
ui_widget_set_tooltip_text(wid, _("Set path from document"));
g_signal_connect(wid, "clicked", G_CALLBACK(on_current_path), NULL);
gtk_container_add(GTK_CONTAINER(toolbar), wid);
@ -740,7 +740,7 @@ static GtkWidget *make_toolbar(void)
gtk_container_add(GTK_CONTAINER(toolbar), wid);
wid = (GtkWidget *) gtk_tool_button_new_from_stock(GTK_STOCK_CLEAR);
p_ui->widget_set_tooltip_text(wid, _("Clear the filter"));
ui_widget_set_tooltip_text(wid, _("Clear the filter"));
g_signal_connect(wid, "clicked", G_CALLBACK(on_clear_filter), NULL);
gtk_container_add(GTK_CONTAINER(toolbar), wid);
@ -775,7 +775,7 @@ static gboolean completion_match_func(GtkEntryCompletion *completion, const gcha
gtk_tree_model_get(GTK_TREE_MODEL(file_store), iter,
FILEVIEW_COLUMN_ICON, &icon, FILEVIEW_COLUMN_NAME, &str, -1);
if (str != NULL && icon != NULL && p_utils->str_equal(icon, GTK_STOCK_DIRECTORY) &&
if (str != NULL && icon != NULL && utils_str_equal(icon, GTK_STOCK_DIRECTORY) &&
! g_str_has_suffix(key, G_DIR_SEPARATOR_S))
{
/* key is something like "/tmp/te" and str is a filename like "test",
@ -912,9 +912,9 @@ void plugin_init(GeanyData *data)
load_settings();
/* setup keybindings */
p_keybindings->set_item(plugin_key_group, KB_FOCUS_FILE_LIST, kb_activate,
keybindings_set_item(plugin_key_group, KB_FOCUS_FILE_LIST, kb_activate,
0, 0, "focus_file_list", _("Focus File List"), NULL);
p_keybindings->set_item(plugin_key_group, KB_FOCUS_PATH_ENTRY, kb_activate,
keybindings_set_item(plugin_key_group, KB_FOCUS_PATH_ENTRY, kb_activate,
0, 0, "focus_path_entry", _("Focus Path Entry"), NULL);
}
@ -947,16 +947,16 @@ on_configure_response(GtkDialog *dialog, gint response, gpointer user_data)
g_key_file_set_boolean(config, "filebrowser", "show_hidden_files", show_hidden_files);
g_key_file_set_boolean(config, "filebrowser", "hide_object_files", hide_object_files);
if (! g_file_test(config_dir, G_FILE_TEST_IS_DIR) && p_utils->mkdir(config_dir, TRUE) != 0)
if (! g_file_test(config_dir, G_FILE_TEST_IS_DIR) && utils_mkdir(config_dir, TRUE) != 0)
{
p_dialogs->show_msgbox(GTK_MESSAGE_ERROR,
dialogs_show_msgbox(GTK_MESSAGE_ERROR,
_("Plugin configuration directory could not be created."));
}
else
{
/* write config to file */
data = g_key_file_to_data(config, NULL, NULL);
p_utils->write_file(config_file, data);
utils_write_file(config_file, data);
g_free(data);
}
@ -983,7 +983,7 @@ GtkWidget *plugin_configure(GtkDialog *dialog)
gtk_widget_show(entry);
if (open_cmd != NULL)
gtk_entry_set_text(GTK_ENTRY(entry), open_cmd);
p_ui->widget_set_tooltip_text(entry,
ui_widget_set_tooltip_text(entry,
_("The command to execute when using \"Open with\". You can use %f and %d wildcards.\n"
"%f will be replaced with the filename including full path\n"
"%d will be replaced with the path name of the selected file without the filename"));
@ -999,7 +999,7 @@ GtkWidget *plugin_configure(GtkDialog *dialog)
checkbox_of = gtk_check_button_new_with_label(_("Hide object files"));
gtk_button_set_focus_on_click(GTK_BUTTON(checkbox_of), FALSE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox_of), hide_object_files);
p_ui->widget_set_tooltip_text(checkbox_of,
ui_widget_set_tooltip_text(checkbox_of,
_("Don't show generated object files in the file browser, this includes "
"*.o, *.obj. *.so, *.dll, *.a, *.lib"));
gtk_box_pack_start(GTK_BOX(vbox), checkbox_of, FALSE, FALSE, 5);

View File

@ -32,7 +32,7 @@
#include "keybindings.h"
#include "ui_utils.h"
#include "utils.h"
#include "pluginmacros.h"
#include "geanyfunctions.h"
GeanyData *geany_data;
@ -89,7 +89,7 @@ static void tools_show_dialog_insert_special_chars(void)
_("Special Characters"), GTK_WINDOW(geany->main_widgets->window),
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("_Insert"), GTK_RESPONSE_OK, NULL);
vbox = p_ui->dialog_vbox_new(GTK_DIALOG(sc_dialog));
vbox = ui_dialog_vbox_new(GTK_DIALOG(sc_dialog));
gtk_box_set_spacing(GTK_BOX(vbox), 6);
gtk_widget_set_name(sc_dialog, "GeanyDialog");
@ -439,18 +439,18 @@ static void sc_fill_store(GtkTreeStore *store)
* returns only TRUE if a valid selection(i.e. no category) could be found */
static gboolean sc_insert(GtkTreeModel *model, GtkTreeIter *iter)
{
GeanyDocument *doc = p_document->get_current();
GeanyDocument *doc = document_get_current();
gboolean result = FALSE;
if (doc != NULL)
{
gchar *str;
gint pos = p_sci->get_current_position(doc->editor->sci);
gint pos = sci_get_current_position(doc->editor->sci);
gtk_tree_model_get(model, iter, COLUMN_HTML_NAME, &str, -1);
if (NZV(str))
{
p_sci->insert_text(doc->editor->sci, pos, str);
sci_insert_text(doc->editor->sci, pos, str);
g_free(str);
result = TRUE;
}
@ -532,11 +532,11 @@ void plugin_init(GeanyData *data)
g_signal_connect(menu_item, "activate", G_CALLBACK(item_activate), NULL);
/* disable menu_item when there are no documents open */
p_ui->add_document_sensitive(menu_item);
ui_add_document_sensitive(menu_item);
main_menu_item = menu_item;
/* setup keybindings */
p_keybindings->set_item(plugin_key_group, KB_INSERT_HTML_CHARS, kb_activate,
keybindings_set_item(plugin_key_group, KB_INSERT_HTML_CHARS, kb_activate,
0, 0, "insert_html_chars", kb_label, menu_item);
}

View File

@ -31,7 +31,7 @@
#include "filetypes.h"
#include "plugindata.h"
#include "pluginmacros.h"
#include "geanyfunctions.h"
#include <unistd.h>
#include <errno.h>
@ -102,7 +102,7 @@ static gboolean backupcopy_set_backup_dir(const gchar *utf8_dir)
if (! NZV(utf8_dir))
return FALSE;
tmp = p_utils->get_locale_from_utf8(utf8_dir);
tmp = utils_get_locale_from_utf8(utf8_dir);
if (! g_path_is_absolute(tmp) ||
! g_file_test(tmp, G_FILE_TEST_EXISTS) ||
@ -171,10 +171,10 @@ static gchar *backupcopy_create_dir_parts(const gchar *filename)
result = backupcopy_skip_root(cp); /* skip leading slash/backslash and c:\ */
target_dir = g_build_filename(backupcopy_backup_dir, result, NULL);
error = p_utils->mkdir(target_dir, TRUE);
error = utils_mkdir(target_dir, TRUE);
if (error != 0)
{
p_ui->set_statusbar(FALSE, _("Backup Copy: Directory could not be created (%s)."),
ui_set_statusbar(FALSE, _("Backup Copy: Directory could not be created (%s)."),
g_strerror(error));
result = g_strdup(""); /* return an empty string in case of an error */
@ -201,18 +201,18 @@ static void backupcopy_document_save_cb(GObject *obj, GeanyDocument *doc, gpoint
if (! enable_backupcopy)
return;
locale_filename_src = p_utils->get_locale_from_utf8(doc->file_name);
locale_filename_src = utils_get_locale_from_utf8(doc->file_name);
if ((src = g_fopen(locale_filename_src, "r")) == NULL)
{
/* it's unlikely that this happens */
p_ui->set_statusbar(FALSE, _("Backup Copy: File could not be read (%s)."),
ui_set_statusbar(FALSE, _("Backup Copy: File could not be read (%s)."),
g_strerror(errno));
g_free(locale_filename_src);
return;
}
stamp = p_utils->get_date_time(backupcopy_time_fmt, NULL);
stamp = utils_get_date_time(backupcopy_time_fmt, NULL);
basename_src = g_path_get_basename(locale_filename_src);
dir_parts_src = backupcopy_create_dir_parts(locale_filename_src);
locale_filename_dst = g_strconcat(
@ -224,7 +224,7 @@ static void backupcopy_document_save_cb(GObject *obj, GeanyDocument *doc, gpoint
if ((dst = g_fopen(locale_filename_dst, "wb")) == NULL)
{
p_ui->set_statusbar(FALSE, _("Backup Copy: File could not be saved (%s)."),
ui_set_statusbar(FALSE, _("Backup Copy: File could not be saved (%s)."),
g_strerror(errno));
g_free(locale_filename_src);
g_free(locale_filename_dst);
@ -261,7 +261,7 @@ static void instantsave_document_new_cb(GObject *obj, GeanyDocument *doc, gpoint
if (ft == NULL)
/* ft is NULL when a new file without template was opened, so use the
* configured default file type */
ft = p_filetypes->lookup_by_name(instantsave_default_ft);
ft = filetypes_lookup_by_name(instantsave_default_ft);
if (ft != NULL)
/* add the filetype's default extension to the new filename */
@ -270,10 +270,10 @@ static void instantsave_document_new_cb(GObject *obj, GeanyDocument *doc, gpoint
doc->file_name = new_filename;
if (FILETYPE_ID(doc->file_type) == GEANY_FILETYPES_NONE)
p_document->set_filetype(doc, p_filetypes->lookup_by_name(instantsave_default_ft));
document_set_filetype(doc, filetypes_lookup_by_name(instantsave_default_ft));
/* force saving the file to enable all the related actions(tab name, filetype, etc.) */
p_document->save_file(doc, TRUE);
document_save_file(doc, TRUE);
}
}
@ -289,7 +289,7 @@ PluginCallback plugin_callbacks[] =
gboolean auto_save(gpointer data)
{
GeanyDocument *doc;
GeanyDocument *cur_doc = p_document->get_current();
GeanyDocument *cur_doc = document_get_current();
gint i, max = gtk_notebook_get_n_pages(GTK_NOTEBOOK(geany->main_widgets->notebook));
gint saved_files = 0;
@ -300,22 +300,22 @@ gboolean auto_save(gpointer data)
{
for (i = 0; i < max; i++)
{
doc = p_document->get_from_page(i);
doc = document_get_from_page(i);
/* skip current file to save it lastly, skip files without name */
if (doc != cur_doc && cur_doc->file_name != NULL)
if (p_document->save_file(doc, FALSE))
if (document_save_file(doc, FALSE))
saved_files++;
}
}
/* finally save current file, do it after all other files to get correct window title and
* symbol list */
if (cur_doc->file_name != NULL)
if (p_document->save_file(cur_doc, FALSE))
if (document_save_file(cur_doc, FALSE))
saved_files++;
if (saved_files > 0 && autosave_print_msg)
p_ui->set_statusbar(FALSE, ngettext(
ui_set_statusbar(FALSE, ngettext(
"Autosave: Saved %d file automatically.",
"Autosave: Saved %d files automatically.", saved_files),
saved_files);
@ -345,27 +345,27 @@ void plugin_init(GeanyData *data)
g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL);
enable_autosave = p_utils->get_setting_boolean(
enable_autosave = utils_get_setting_boolean(
config, "saveactions", "enable_autosave", FALSE);
enable_instantsave = p_utils->get_setting_boolean(
enable_instantsave = utils_get_setting_boolean(
config, "saveactions", "enable_instantsave", FALSE);
enable_backupcopy = p_utils->get_setting_boolean(
enable_backupcopy = utils_get_setting_boolean(
config, "saveactions", "enable_backupcopy", FALSE);
instantsave_default_ft = p_utils->get_setting_string(config, "instantsave", "default_ft",
instantsave_default_ft = utils_get_setting_string(config, "instantsave", "default_ft",
filetypes[GEANY_FILETYPES_NONE]->name);
autosave_src_id = G_MAXUINT; /* mark as invalid */
autosave_interval = p_utils->get_setting_integer(config, "autosave", "interval", 300);
autosave_print_msg = p_utils->get_setting_boolean(config, "autosave", "print_messages", FALSE);
autosave_save_all = p_utils->get_setting_boolean(config, "autosave", "save_all", FALSE);
autosave_interval = utils_get_setting_integer(config, "autosave", "interval", 300);
autosave_print_msg = utils_get_setting_boolean(config, "autosave", "print_messages", FALSE);
autosave_save_all = utils_get_setting_boolean(config, "autosave", "save_all", FALSE);
if (enable_autosave)
autosave_set_timeout();
backupcopy_dir_levels = p_utils->get_setting_integer(config, "backupcopy", "dir_levels", 0);
backupcopy_time_fmt = p_utils->get_setting_string(
backupcopy_dir_levels = utils_get_setting_integer(config, "backupcopy", "dir_levels", 0);
backupcopy_time_fmt = utils_get_setting_string(
config, "backupcopy", "time_fmt", "%Y-%m-%d-%H-%M-%S");
tmp = p_utils->get_setting_string(config, "backupcopy", "backup_dir", g_get_tmp_dir());
tmp = utils_get_setting_string(config, "backupcopy", "backup_dir", g_get_tmp_dir());
backupcopy_set_backup_dir(tmp);
g_key_file_free(config);
@ -390,7 +390,7 @@ static void backupcopy_dir_button_clicked_cb(GtkButton *button, gpointer item)
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
text = p_utils->get_locale_from_utf8(gtk_entry_get_text(GTK_ENTRY(item)));
text = utils_get_locale_from_utf8(gtk_entry_get_text(GTK_ENTRY(item)));
if (NZV(text))
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), text);
@ -400,7 +400,7 @@ static void backupcopy_dir_button_clicked_cb(GtkButton *button, gpointer item)
gchar *utf8_filename, *tmp;
tmp = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
utf8_filename = p_utils->get_utf8_from_locale(tmp);
utf8_filename = utils_get_utf8_from_locale(tmp);
gtk_entry_set_text(GTK_ENTRY(item), utf8_filename);
@ -466,21 +466,21 @@ static void configure_response_cb(GtkDialog *dialog, gint response, G_GNUC_UNUSE
}
else
{
p_dialogs->show_msgbox(GTK_MESSAGE_ERROR,
dialogs_show_msgbox(GTK_MESSAGE_ERROR,
_("Backup directory does not exist or is not writable."));
}
if (! g_file_test(config_dir, G_FILE_TEST_IS_DIR) && p_utils->mkdir(config_dir, TRUE) != 0)
if (! g_file_test(config_dir, G_FILE_TEST_IS_DIR) && utils_mkdir(config_dir, TRUE) != 0)
{
p_dialogs->show_msgbox(GTK_MESSAGE_ERROR,
dialogs_show_msgbox(GTK_MESSAGE_ERROR,
_("Plugin configuration directory could not be created."));
}
else
{
/* write config to file */
str = g_key_file_to_data(config, NULL, NULL);
p_utils->write_file(config_file, str);
utils_write_file(config_file, str);
g_free(str);
}
@ -627,7 +627,7 @@ GtkWidget *plugin_configure(GtkDialog *dialog)
{
gtk_combo_box_append_text(GTK_COMBO_BOX(combo), filetypes[i]->name);
if (p_utils->str_equal(filetypes[i]->name, instantsave_default_ft))
if (utils_str_equal(filetypes[i]->name, instantsave_default_ft))
gtk_combo_box_set_active(GTK_COMBO_BOX(combo), i);
}
gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(combo), 3);

View File

@ -34,7 +34,7 @@
#include "document.h"
#include "editor.h"
#include "plugindata.h"
#include "pluginmacros.h"
#include "geanyfunctions.h"
PLUGIN_VERSION_CHECK(GEANY_API_VERSION)
@ -83,7 +83,7 @@ static void on_unsplit(GtkMenuItem *menuitem, gpointer user_data);
static gint sci_get_value(ScintillaObject *sci, gint message_id, gint param)
{
return p_sci->send_message(sci, message_id, param, 0);
return scintilla_send_message(sci, message_id, param, 0);
}
@ -96,13 +96,13 @@ static void set_styles(ScintillaObject *oldsci, ScintillaObject *newsci)
gint val;
val = sci_get_value(oldsci, SCI_STYLEGETFORE, style_id);
p_sci->send_message(newsci, SCI_STYLESETFORE, style_id, val);
scintilla_send_message(newsci, SCI_STYLESETFORE, style_id, val);
val = sci_get_value(oldsci, SCI_STYLEGETBACK, style_id);
p_sci->send_message(newsci, SCI_STYLESETBACK, style_id, val);
scintilla_send_message(newsci, SCI_STYLESETBACK, style_id, val);
val = sci_get_value(oldsci, SCI_STYLEGETBOLD, style_id);
p_sci->send_message(newsci, SCI_STYLESETBOLD, style_id, val);
scintilla_send_message(newsci, SCI_STYLESETBOLD, style_id, val);
val = sci_get_value(oldsci, SCI_STYLEGETITALIC, style_id);
p_sci->send_message(newsci, SCI_STYLESETITALIC, style_id, val);
scintilla_send_message(newsci, SCI_STYLESETITALIC, style_id, val);
}
}
@ -110,8 +110,8 @@ static void set_styles(ScintillaObject *oldsci, ScintillaObject *newsci)
static void sci_set_font(ScintillaObject *sci, gint style, const gchar *font,
gint size)
{
p_sci->send_message(sci, SCI_STYLESETFONT, style, (sptr_t) font);
p_sci->send_message(sci, SCI_STYLESETSIZE, style, size);
scintilla_send_message(sci, SCI_STYLESETFONT, style, (sptr_t) font);
scintilla_send_message(sci, SCI_STYLESETSIZE, style, size);
}
@ -121,7 +121,7 @@ static void update_font(ScintillaObject *current, ScintillaObject *sci)
gint size;
gchar font_name[1024]; /* should be big enough */
p_sci->send_message(current, SCI_STYLEGETFONT, 0, (sptr_t)font_name);
scintilla_send_message(current, SCI_STYLEGETFONT, 0, (sptr_t)font_name);
size = sci_get_value(current, SCI_STYLEGETSIZE, 0);
for (style_id = 0; style_id <= 127; style_id++)
@ -142,16 +142,16 @@ static void set_line_numbers(ScintillaObject * sci, gboolean set, gint extra_wid
if (set)
{
gchar tmp_str[15];
gint len = p_sci->send_message(sci, SCI_GETLINECOUNT, 0, 0);
gint len = scintilla_send_message(sci, SCI_GETLINECOUNT, 0, 0);
gint width;
g_snprintf(tmp_str, 15, "_%d%d", len, extra_width);
width = p_sci->send_message(sci, SCI_TEXTWIDTH, STYLE_LINENUMBER, (sptr_t) tmp_str);
p_sci->send_message(sci, SCI_SETMARGINWIDTHN, 0, width);
p_sci->send_message(sci, SCI_SETMARGINSENSITIVEN, 0, FALSE); /* use default behaviour */
width = scintilla_send_message(sci, SCI_TEXTWIDTH, STYLE_LINENUMBER, (sptr_t) tmp_str);
scintilla_send_message(sci, SCI_SETMARGINWIDTHN, 0, width);
scintilla_send_message(sci, SCI_SETMARGINSENSITIVEN, 0, FALSE); /* use default behaviour */
}
else
{
p_sci->send_message(sci, SCI_SETMARGINWIDTHN, 0, 0 );
scintilla_send_message(sci, SCI_SETMARGINWIDTHN, 0, 0 );
}
}
@ -163,20 +163,20 @@ static void sync_to_current(ScintillaObject *sci, ScintillaObject *current)
gint pos;
/* set the new sci widget to view the existing Scintilla document */
sdoc = (gpointer) p_sci->send_message(current, SCI_GETDOCPOINTER, 0, 0);
p_sci->send_message(sci, SCI_SETDOCPOINTER, 0, GPOINTER_TO_INT(sdoc));
sdoc = (gpointer) scintilla_send_message(current, SCI_GETDOCPOINTER, 0, 0);
scintilla_send_message(sci, SCI_SETDOCPOINTER, 0, GPOINTER_TO_INT(sdoc));
update_font(current, sci);
lexer = p_sci->send_message(current, SCI_GETLEXER, 0, 0);
p_sci->send_message(sci, SCI_SETLEXER, lexer, 0);
lexer = scintilla_send_message(current, SCI_GETLEXER, 0, 0);
scintilla_send_message(sci, SCI_SETLEXER, lexer, 0);
set_styles(current, sci);
pos = p_sci->get_current_position(current);
p_sci->set_current_position(sci, pos, TRUE);
pos = sci_get_current_position(current);
sci_set_current_position(sci, pos, TRUE);
/* override some defaults */
set_line_numbers(sci, TRUE, 0);
p_sci->send_message(sci, SCI_SETMARGINWIDTHN, 1, 0 ); /* hide marker margin */
scintilla_send_message(sci, SCI_SETMARGINWIDTHN, 1, 0 ); /* hide marker margin */
}
@ -189,7 +189,7 @@ static void set_editor(EditWindow *editwin, GeanyEditor *editor)
if (editwin->sci != NULL)
gtk_widget_destroy(GTK_WIDGET(editwin->sci));
editwin->sci = p_editor->create_widget(editor);
editwin->sci = editor_create_widget(editor);
gtk_widget_show(GTK_WIDGET(editwin->sci));
gtk_container_add(GTK_CONTAINER(editwin->vbox), GTK_WIDGET(editwin->sci));
@ -218,7 +218,7 @@ static GtkWidget *create_tool_button(const gchar *label, const gchar *stock_id)
item = gtk_tool_button_new(NULL, label);
gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(item), stock_id);
p_ui->widget_set_tooltip_text(GTK_WIDGET(item), label);
ui_widget_set_tooltip_text(GTK_WIDGET(item), label);
return GTK_WIDGET(item);
}
@ -226,7 +226,7 @@ static GtkWidget *create_tool_button(const gchar *label, const gchar *stock_id)
static void on_refresh(void)
{
GeanyDocument *doc = p_document->get_current();
GeanyDocument *doc = document_get_current();
g_return_if_fail(doc);
g_return_if_fail(edit_window.sci);
@ -282,7 +282,7 @@ static void split_view(gboolean horizontal)
GtkWidget *notebook = geany_data->main_widgets->notebook;
GtkWidget *parent = gtk_widget_get_parent(notebook);
GtkWidget *pane, *toolbar, *box;
GeanyDocument *doc = p_document->get_current();
GeanyDocument *doc = document_get_current();
gint width = notebook->allocation.width / 2;
gint height = notebook->allocation.height / 2;
@ -294,7 +294,7 @@ static void split_view(gboolean horizontal)
/* temporarily put document notebook in main vbox (scintilla widgets must stay
* in a visible parent window, otherwise there are X selection and scrollbar issues) */
gtk_widget_reparent(notebook,
p_support->lookup_widget(geany->main_widgets->window, "vbox1"));
ui_lookup_widget(geany->main_widgets->window, "vbox1"));
pane = horizontal ? gtk_hpaned_new() : gtk_vpaned_new();
gtk_container_add(GTK_CONTAINER(parent), pane);
@ -345,7 +345,7 @@ static void on_unsplit(GtkMenuItem *menuitem, gpointer user_data)
/* temporarily put document notebook in main vbox (scintilla widgets must stay
* in a visible parent window, otherwise there are X selection and scrollbar issues) */
gtk_widget_reparent(notebook,
p_support->lookup_widget(geany->main_widgets->window, "vbox1"));
ui_lookup_widget(geany->main_widgets->window, "vbox1"));
gtk_widget_destroy(pane);
edit_window.editor = NULL;
@ -360,7 +360,7 @@ void plugin_init(GeanyData *data)
menu_items.main = item = gtk_menu_item_new_with_mnemonic(_("_Split Window"));
gtk_menu_append(geany_data->main_widgets->tools_menu, item);
p_ui->add_document_sensitive(item);
ui_add_document_sensitive(item);
menu = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_items.main), menu);

View File

@ -38,7 +38,7 @@
#include "utils.h"
#include "project.h"
#include "ui_utils.h"
#include "pluginmacros.h"
#include "geanyfunctions.h"
#define project geany->app->project
@ -270,40 +270,40 @@ static void show_output(const gchar *std_output, const gchar *utf8_name_prefix,
* UTF-8 because internally Geany always needs UTF-8 */
if (force_encoding)
{
text = p_encodings->convert_to_utf8_from_charset(
text = encodings_convert_to_utf8_from_charset(
std_output, (gsize)-1, force_encoding, TRUE);
}
else
{
text = p_encodings->convert_to_utf8(std_output, (gsize)-1, &detect_enc);
text = encodings_convert_to_utf8(std_output, (gsize)-1, &detect_enc);
}
if (text)
{
GeanyIndentType indent_type =
p_document->get_current()->editor->indent_type;
document_get_current()->editor->indent_type;
doc = p_document->find_by_filename(filename);
doc = document_find_by_filename(filename);
if (doc == NULL)
{
GeanyFiletype *ft = p_filetypes->lookup_by_name("Diff");
doc = p_document->new_file(filename, ft, text);
GeanyFiletype *ft = filetypes_lookup_by_name("Diff");
doc = document_new_file(filename, ft, text);
}
else
{
p_sci->set_text(doc->editor->sci, text);
sci_set_text(doc->editor->sci, text);
book = GTK_NOTEBOOK(geany->main_widgets->notebook);
page = gtk_notebook_page_num(book, GTK_WIDGET(doc->editor->sci));
gtk_notebook_set_current_page(book, page);
p_document->set_text_changed(doc, FALSE);
document_set_text_changed(doc, FALSE);
}
p_editor->set_indent_type(doc->editor, indent_type);
editor_set_indent_type(doc->editor, indent_type);
p_document->set_encoding(doc,
document_set_encoding(doc,
force_encoding ? force_encoding : detect_enc);
}
else
{
p_ui->set_statusbar(FALSE, _("Input conversion of the diff output failed."));
ui_set_statusbar(FALSE, _("Input conversion of the diff output failed."));
}
g_free(text);
g_free(detect_enc);
@ -339,13 +339,13 @@ static gchar *make_diff(const gchar *filename, gint cmd)
dir = g_path_get_dirname(filename);
}
if (p_utils->spawn_sync(dir, argv, env, G_SPAWN_SEARCH_PATH, NULL, NULL,
if (utils_spawn_sync(dir, argv, env, G_SPAWN_SEARCH_PATH, NULL, NULL,
&std_output, &std_error, &exit_code, &error))
{
/* CVS dump stuff to stderr when diff nested dirs */
if (strcmp(argv[0], "cvs") != 0 && NZV(std_error))
{
p_dialogs->show_msgbox(1,
dialogs_show_msgbox(1,
_("%s exited with an error: \n%s."), argv[0], g_strstrip(std_error));
}
else if (NZV(std_output))
@ -354,7 +354,7 @@ static gchar *make_diff(const gchar *filename, gint cmd)
}
else
{
p_ui->set_statusbar(FALSE, _("No changes were made."));
ui_set_statusbar(FALSE, _("No changes were made."));
}
/* win32_spawn() returns sometimes TRUE but error is set anyway, has to be fixed */
if (error != NULL)
@ -376,7 +376,7 @@ static gchar *make_diff(const gchar *filename, gint cmd)
msg = g_strdup_printf(_("unknown error while trying to spawn a process for %s"),
argv[0]);
}
p_ui->set_statusbar(FALSE, _("An error occurred (%s)."), msg);
ui_set_statusbar(FALSE, _("An error occurred (%s)."), msg);
g_free(msg);
}
@ -396,22 +396,22 @@ static void vcdirectory_activated(GtkMenuItem *menuitem, gpointer gdata)
gchar *locale_filename = NULL;
gchar *text;
doc = p_document->get_current();
doc = document_get_current();
g_return_if_fail(doc != NULL && doc->file_name != NULL);
if (doc->changed)
{
p_document->save_file(doc, FALSE);
document_save_file(doc, FALSE);
}
locale_filename = p_utils->get_locale_from_utf8(doc->file_name);
locale_filename = utils_get_locale_from_utf8(doc->file_name);
base_name = g_path_get_dirname(locale_filename);
text = make_diff(base_name, VC_COMMAND_DIFF_DIR);
if (text)
{
setptr(base_name, p_utils->get_utf8_from_locale(base_name));
setptr(base_name, utils_get_utf8_from_locale(base_name));
show_output(text, base_name, NULL);
g_free(text);
}
@ -428,16 +428,16 @@ static void vcproject_activated(GtkMenuItem *menuitem, gpointer gdata)
gchar *locale_filename = NULL;
gchar *text;
doc = p_document->get_current();
doc = document_get_current();
g_return_if_fail(project != NULL && NZV(project->base_path));
if (doc != NULL && doc->changed && doc->file_name != NULL)
{
p_document->save_file(doc, FALSE);
document_save_file(doc, FALSE);
}
locale_filename = p_utils->get_locale_from_utf8(project->base_path);
locale_filename = utils_get_locale_from_utf8(project->base_path);
text = make_diff(locale_filename, VC_COMMAND_DIFF_PROJECT);
if (text)
{
@ -454,16 +454,16 @@ static void vcfile_activated(GtkMenuItem *menuitem, gpointer gdata)
GeanyDocument *doc;
gchar *locale_filename, *text;
doc = p_document->get_current();
doc = document_get_current();
g_return_if_fail(doc != NULL && doc->file_name != NULL);
if (doc->changed)
{
p_document->save_file(doc, FALSE);
document_save_file(doc, FALSE);
}
locale_filename = p_utils->get_locale_from_utf8(doc->file_name);
locale_filename = utils_get_locale_from_utf8(doc->file_name);
text = make_diff(locale_filename, VC_COMMAND_DIFF_FILE);
if (text)
@ -485,7 +485,7 @@ static void update_menu_items(void)
gboolean have_file;
gboolean have_vc = FALSE;
doc = p_document->get_current();
doc = document_get_current();
have_file = doc && doc->file_name && g_path_is_absolute(doc->file_name);
if (find_cmd_env(VC_COMMAND_DIFF_FILE, TRUE, doc->file_name))
have_vc = TRUE;
@ -514,14 +514,14 @@ void plugin_init(GeanyData *data)
/* Single file */
menu_vcdiff_file = gtk_menu_item_new_with_mnemonic(_("From Current _File"));
gtk_container_add(GTK_CONTAINER (menu_vcdiff_menu), menu_vcdiff_file);
p_ui->widget_set_tooltip_text(menu_vcdiff_file, _("Make a diff from the current active file"));
ui_widget_set_tooltip_text(menu_vcdiff_file, _("Make a diff from the current active file"));
g_signal_connect(menu_vcdiff_file, "activate", G_CALLBACK(vcfile_activated), NULL);
/* Directory */
menu_vcdiff_dir = gtk_menu_item_new_with_mnemonic(_("From Current _Directory"));
gtk_container_add(GTK_CONTAINER (menu_vcdiff_menu), menu_vcdiff_dir);
p_ui->widget_set_tooltip_text(menu_vcdiff_dir,
ui_widget_set_tooltip_text(menu_vcdiff_dir,
_("Make a diff from the directory of the current active file"));
g_signal_connect(menu_vcdiff_dir, "activate", G_CALLBACK(vcdirectory_activated), NULL);
@ -529,14 +529,14 @@ void plugin_init(GeanyData *data)
/* Project */
menu_vcdiff_project = gtk_menu_item_new_with_mnemonic(_("From Current _Project"));
gtk_container_add(GTK_CONTAINER (menu_vcdiff_menu), menu_vcdiff_project);
p_ui->widget_set_tooltip_text(menu_vcdiff_project,
ui_widget_set_tooltip_text(menu_vcdiff_project,
_("Make a diff from the current project's base path"));
g_signal_connect(menu_vcdiff_project, "activate", G_CALLBACK(vcproject_activated), NULL);
gtk_widget_show_all(menu_vcdiff);
p_ui->add_document_sensitive(menu_vcdiff);
ui_add_document_sensitive(menu_vcdiff);
main_menu_item = menu_vcdiff;
}