Remove deprecated macros and typedefs (except DOC_IDX_*), as some of

them are likely to cause naming conflicts and all plugins will need
updating since 0.14 anyway.
Add geany macro that simply expands to geany_data.
Deprecate app, main_widgets, prefs, project macros, as the geany
macro can be used instead.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2761 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2008-07-07 16:16:18 +00:00
parent 61bea15355
commit 18ced215d1
11 changed files with 57 additions and 96 deletions

View File

@ -7,6 +7,16 @@
'Newline strips trailing spaces' pref.
* doc/plugin-symbols.c, doc/Makefile.am, doc/plugins.dox:
Rename plugin-symbols.c pluginsymbols.c.
* src/plugindata.h, doc/plugins.dox, plugins/export.c,
plugins/vcdiff.c, plugins/demoplugin.c, plugins/filebrowser.c,
plugins/htmlchars.c, plugins/autosave.c, plugins/pluginmacros.h,
plugins/classbuilder.c:
Remove deprecated macros and typedefs (except DOC_IDX_*), as some of
them are likely to cause naming conflicts and all plugins will need
updating since 0.14 anyway.
Add geany macro that simply expands to geany_data.
Deprecate app, main_widgets, prefs, project macros, as the geany
macro can be used instead.
2008-07-05 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>

View File

@ -166,7 +166,9 @@ PluginCallback plugin_callbacks[] =
* @endsignalproto
* @signaldesc
* Sent before the popup menu of the editing widget is shown. This can be used to modify or extend
* the popup menu. You can access the menu pointer using @a main_widgets->editor_menu.
* the popup menu.
* @note You can add menu items from @c plugin_init() using @c geany->main_widgets->editor_menu,
* remembering to destroy them in @c plugin_cleanup().
* @param obj a GeanyObject instance, should be ignored.
* @param word the current word (in UTF-8 encoding) below the cursor position
where the popup menu will be opened.

View File

@ -54,7 +54,7 @@ gboolean auto_save(gpointer data)
{
GeanyDocument *doc;
GeanyDocument *cur_doc = p_document->get_current();
gint i, max = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets->notebook));
gint i, max = gtk_notebook_get_n_pages(GTK_NOTEBOOK(geany->main_widgets->notebook));
gint saved_files = 0;
if (save_all)
@ -98,7 +98,7 @@ void plugin_init(GeanyData *data)
{
GKeyFile *config = g_key_file_new();
GError *error = NULL;
config_file = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S,
config_file = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S,
"autosave", G_DIR_SEPARATOR_S, "autosave.conf", NULL);
g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL);

View File

@ -355,7 +355,7 @@ void show_dialog_create_class(gint type)
cc_dlg->class_type = type;
cc_dlg->dialog = gtk_dialog_new_with_buttons(_("Create Class"),
GTK_WINDOW(main_widgets->window),
GTK_WINDOW(geany->main_widgets->window),
GTK_DIALOG_MODAL,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
@ -778,7 +778,7 @@ void plugin_init(GeanyData *data)
GtkWidget *menu_create_gtk_class;
menu_create_class1 = gtk_image_menu_item_new_with_mnemonic (_("Create Cla_ss"));
gtk_container_add (GTK_CONTAINER (main_widgets->tools_menu), menu_create_class1);
gtk_container_add (GTK_CONTAINER (geany->main_widgets->tools_menu), menu_create_class1);
image1861 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_create_class1), image1861);

View File

@ -40,7 +40,7 @@
#include "ui_utils.h"
#include "plugindata.h" /* this defines the plugin API */
#include "pluginmacros.h" /* some useful macros to avoid typing geany_data so often */
#include "pluginmacros.h" /* some useful macros to save typing */
/* These items are set by Geany before plugin_init() is called. */
@ -69,7 +69,7 @@ item_activate(GtkMenuItem *menuitem, gpointer gdata)
GtkWidget *dialog;
dialog = gtk_message_dialog_new(
GTK_WINDOW(main_widgets->window),
GTK_WINDOW(geany->main_widgets->window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
@ -91,7 +91,7 @@ void plugin_init(GeanyData *data)
/* Add an item to the Tools menu */
demo_item = gtk_menu_item_new_with_mnemonic(_("_Demo Plugin"));
gtk_widget_show(demo_item);
gtk_container_add(GTK_CONTAINER(main_widgets->tools_menu), demo_item);
gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), demo_item);
g_signal_connect(G_OBJECT(demo_item), "activate", G_CALLBACK(item_activate), NULL);
welcome_text = g_strdup(_("Hello World!"));
@ -116,8 +116,8 @@ on_configure_response(GtkDialog *dialog, gint response, gpointer user_data)
/* maybe the plugin should write here the settings into a file
* (e.g. using GLib's GKeyFile API)
* all plugin specific files should be created in:
* app->configdir G_DIR_SEPARATOR_S plugins G_DIR_SEPARATOR_S pluginname G_DIR_SEPARATOR_S
* e.g. this could be: ~/.geany/plugins/Demo/, please use app->configdir */
* geany->app->configdir G_DIR_SEPARATOR_S plugins G_DIR_SEPARATOR_S pluginname G_DIR_SEPARATOR_S
* e.g. this could be: ~/.geany/plugins/Demo/, please use geany->app->configdir */
}
}

View File

@ -163,14 +163,14 @@ static void create_file_save_as_dialog(const gchar *extension, ExportFunc func,
return;
doc = p_document->get_current();
tooltips = GTK_TOOLTIPS(p_support->lookup_widget(main_widgets->window, "tooltips"));
tooltips = GTK_TOOLTIPS(p_support->lookup_widget(geany->main_widgets->window, "tooltips"));
exi = g_new(ExportInfo, 1);
exi->doc = doc;
exi->export_func = func;
exi->have_zoom_level_checkbox = FALSE;
dialog = gtk_file_chooser_dialog_new(_("Export File"), GTK_WINDOW(main_widgets->window),
dialog = gtk_file_chooser_dialog_new(_("Export File"), GTK_WINDOW(geany->main_widgets->window),
GTK_FILE_CHOOSER_ACTION_SAVE, NULL, NULL);
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
@ -205,7 +205,7 @@ static void create_file_save_as_dialog(const gchar *extension, ExportFunc func,
g_signal_connect((gpointer) dialog, "response",
G_CALLBACK(on_file_save_dialog_response), exi);
gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(main_widgets->window));
gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(geany->main_widgets->window));
/* if the current document has a filename we use it as the default. */
gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(dialog));
@ -236,7 +236,7 @@ static void create_file_save_as_dialog(const gchar *extension, ExportFunc func,
}
else
{
const gchar *default_open_path = prefs->default_open_path;
const gchar *default_open_path = geany->prefs->default_open_path;
gchar *fname = g_strconcat(GEANY_STRING_UNTITLED, extension, NULL);
gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(dialog));
@ -410,8 +410,8 @@ static void write_latex_file(GeanyDocument *doc, const gchar *filename, gboolean
}
case '\t':
{
gint tab_stop = geany_data->editor_prefs->tab_width -
(column % geany_data->editor_prefs->tab_width);
gint tab_stop = geany->editor_prefs->tab_width -
(column % geany->editor_prefs->tab_width);
column += tab_stop - 1; /* -1 because we add 1 at the end of the loop */
g_string_append_printf(body, "\\hspace*{%dem}", tab_stop);
@ -577,7 +577,7 @@ static void write_html_file(GeanyDocument *doc, const gchar *filename, gboolean
}
/* read Geany's font and font size */
font_desc = pango_font_description_from_string(geany_data->interface_prefs->editor_font);
font_desc = pango_font_description_from_string(geany->interface_prefs->editor_font);
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 */
@ -627,8 +627,8 @@ static void write_html_file(GeanyDocument *doc, const gchar *filename, gboolean
case '\t':
{
gint j;
gint tab_stop = geany_data->editor_prefs->tab_width -
(column % geany_data->editor_prefs->tab_width);
gint tab_stop = geany->editor_prefs->tab_width -
(column % geany->editor_prefs->tab_width);
column += tab_stop - 1; /* -1 because we add 1 at the end of the loop */
for (j = 0; j < tab_stop; j++)
@ -712,7 +712,7 @@ void plugin_init(GeanyData *data)
GtkWidget *menu_create_latex;
menu_export = gtk_image_menu_item_new_with_mnemonic(_("_Export"));
gtk_container_add(GTK_CONTAINER(main_widgets->tools_menu), menu_export);
gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), menu_export);
menu_export_menu = gtk_menu_new ();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_export), menu_export_menu);

View File

@ -261,6 +261,7 @@ static void on_go_home(void)
static gchar *get_default_dir(void)
{
const gchar *dir = NULL;
GeanyProject *project = geany->app->project;
if (project)
dir = project->base_path;
@ -716,7 +717,7 @@ static void prepare_file_view(void)
gtk_tree_view_set_enable_search(GTK_TREE_VIEW(file_view), TRUE);
gtk_tree_view_set_search_column(GTK_TREE_VIEW(file_view), FILEVIEW_COLUMN_NAME);
pfd = pango_font_description_from_string(geany_data->interface_prefs->tagbar_font);
pfd = pango_font_description_from_string(geany->interface_prefs->tagbar_font);
gtk_widget_modify_font(file_view, pfd);
pango_font_description_free(pfd);
@ -738,7 +739,7 @@ static GtkWidget *make_toolbar(void)
{
GtkWidget *wid, *toolbar;
GtkTooltips *tooltips = GTK_TOOLTIPS(p_support->lookup_widget(
main_widgets->window, "tooltips"));
geany->main_widgets->window, "tooltips"));
toolbar = gtk_toolbar_new();
gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar), GTK_ICON_SIZE_MENU);
@ -876,7 +877,7 @@ static void load_settings(void)
GError *error = NULL;
gboolean tmp;
config_file = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S,
config_file = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S,
"filebrowser", G_DIR_SEPARATOR_S, "filebrowser.conf", NULL);
g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL);
open_cmd = g_key_file_get_string(config, "filebrowser", "open_command", &error);
@ -938,7 +939,7 @@ void plugin_init(GeanyData *data)
gtk_container_add(GTK_CONTAINER(file_view_vbox), scrollwin);
gtk_widget_show_all(file_view_vbox);
gtk_notebook_append_page(GTK_NOTEBOOK(main_widgets->sidebar_notebook), file_view_vbox,
gtk_notebook_append_page(GTK_NOTEBOOK(geany->main_widgets->sidebar_notebook), file_view_vbox,
gtk_label_new(_("Files")));
load_settings();

View File

@ -85,7 +85,7 @@ static void tools_show_dialog_insert_special_chars(void)
GtkWidget *swin, *vbox, *label;
sc_dialog = gtk_dialog_new_with_buttons(
_("Special Characters"), GTK_WINDOW(main_widgets->window),
_("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));
@ -528,7 +528,7 @@ void plugin_init(GeanyData *data)
/* Add an item to the Tools menu */
demo_item = gtk_menu_item_new_with_mnemonic(menu_text);
gtk_widget_show(demo_item);
gtk_container_add(GTK_CONTAINER(main_widgets->tools_menu), demo_item);
gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), demo_item);
g_signal_connect(G_OBJECT(demo_item), "activate", G_CALLBACK(item_activate), NULL);
/* disable menu_item when there are no documents open */

View File

@ -35,29 +35,31 @@
#ifndef PLUGINMACROS_H
#define PLUGINMACROS_H
/* common data structs */
#define app geany_data->app
#define main_widgets geany_data->main_widgets
/* common items */
#define geany geany_data /**< Simple macro for @c geany_data that reduces typing. */
#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 */
#ifndef GEANY_DISABLE_DEPRECATED
#define app geany_data->app
#define main_widgets geany_data->main_widgets
#define prefs geany_data->prefs
#define project app->project
#endif
/* 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 */
/* function group macros */
#define p_editor geany_functions->p_editor /**< See editor.h */
#ifdef GEANY_DISABLE_DEPRECATED
#define p_document geany_functions->p_document /**< See document.h */
#define p_dialogs geany_functions->p_dialogs /**< See dialogs.h */
#define p_encodings geany_functions->p_encodings /**< See encodings.h */
#define p_filetypes geany_functions->p_filetypes /**< See filetypes.h */
#define p_highlighting geany_functions->p_highlighting /**< See highlighting.h */
#define p_keybindings geany_functions->p_keybindings /**< See keybindings.h */
#define p_msgwindow geany_functions->p_msgwindow /**< See msgwindow.h */
#define p_navqueue geany_functions->p_navqueue /**< See navqueue.h */
#define p_sci geany_functions->p_sci /**< See sciwrappers.h */
#define p_search geany_functions->p_search /**< See search.h */
#define p_support geany_functions->p_support /**< See support.h */
@ -66,37 +68,4 @@
#define p_ui geany_functions->p_ui /**< See ui_utils.h */
#define p_utils geany_functions->p_utils /**< See utils.h */
#else
#define p_dialogs dialogs
#define p_encodings encodings
#define p_highlighting highlighting
#define p_keybindings keybindings
#define p_msgwindow msgwindow
#define p_sci scintilla
#define p_search search
#define p_support support
#define p_templates templates
#define p_tm tagmanager
#define p_ui ui
#define p_utils utils
/* Temporary source compatibility macros - do not use these in new code, they may get removed. */
#define dialogs geany_functions->p_dialogs
#define encodings geany_functions->p_encodings
#define highlighting geany_functions->p_highlighting
#define keybindings geany_functions->p_keybindings
#define msgwindow geany_functions->p_msgwindow
#define scintilla geany_functions->p_sci
#define search geany_functions->p_search
#define support geany_functions->p_support
#define templates geany_functions->p_templates
#define tagmanager geany_functions->p_tm
#define ui geany_functions->p_ui
#define utils geany_functions->p_utils
#define p_encoding p_encodings
#endif
#endif

View File

@ -39,6 +39,8 @@
#include "ui_utils.h"
#include "pluginmacros.h"
#define project geany->app->project
PluginFields *plugin_fields;
GeanyData *geany_data;
@ -283,7 +285,7 @@ static void show_output(const gchar *std_output, const gchar *utf8_name_prefix,
else
{
p_sci->set_text(doc->sci, text);
book = GTK_NOTEBOOK(main_widgets->notebook);
book = GTK_NOTEBOOK(geany->main_widgets->notebook);
page = gtk_notebook_page_num(book, GTK_WIDGET(doc->sci));
gtk_notebook_set_current_page(book, page);
p_document->set_text_changed(doc, FALSE);
@ -498,7 +500,7 @@ void plugin_init(GeanyData *data)
tooltips = gtk_tooltips_new();
menu_vcdiff = gtk_image_menu_item_new_with_mnemonic(_("_Version Diff"));
gtk_container_add(GTK_CONTAINER(main_widgets->tools_menu), menu_vcdiff);
gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), menu_vcdiff);
g_signal_connect((gpointer) menu_vcdiff, "activate",
G_CALLBACK(update_menu_items), NULL);

View File

@ -36,7 +36,7 @@
/* The API version should be incremented whenever any plugin data types below are
* modified or appended to. */
static const gint api_version = 74;
static const gint api_version = 75;
/* The ABI version should be incremented whenever existing fields in the plugin
* data types below have to be changed or reordered. It should stay the same if fields
@ -438,29 +438,6 @@ EditorFuncs;
/* Deprecated aliases */
#ifndef GEANY_DISABLE_DEPRECATED
typedef GeanyData PluginData; /* for compatibility with API < 7 */
#define VERSION_CHECK(api_required) \
PLUGIN_VERSION_CHECK(api_required)
#define GEANY_MAX_FILE_TYPES \
filetypes_array->len
#define GEANY_FILETYPES_ALL \
GEANY_FILETYPES_NONE
typedef struct GeanyDocument document;
typedef struct GeanyFiletype filetype;
typedef PluginCallback GeanyCallback;
#define geany_callbacks plugin_callbacks
#define PLUGIN_INFO PLUGIN_SET_INFO
#define init plugin_init
#define cleanup plugin_cleanup
#define doc_array documents_array
/** NULL-safe way to get the index of @a doc_ptr in the documents array. */
#define DOC_IDX(doc_ptr) \
(doc_ptr ? doc_ptr->index : -1)