SF.net SVN: geany: [2761] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Mon Jul 7 16:16:32 UTC 2008


Revision: 2761
          http://geany.svn.sourceforge.net/geany/?rev=2761&view=rev
Author:   ntrel
Date:     2008-07-07 09:16:18 -0700 (Mon, 07 Jul 2008)

Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/doc/plugins.dox
    trunk/plugins/autosave.c
    trunk/plugins/classbuilder.c
    trunk/plugins/demoplugin.c
    trunk/plugins/export.c
    trunk/plugins/filebrowser.c
    trunk/plugins/htmlchars.c
    trunk/plugins/pluginmacros.h
    trunk/plugins/vcdiff.c
    trunk/src/plugindata.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-07-07 13:08:07 UTC (rev 2760)
+++ trunk/ChangeLog	2008-07-07 16:16:18 UTC (rev 2761)
@@ -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>

Modified: trunk/doc/plugins.dox
===================================================================
--- trunk/doc/plugins.dox	2008-07-07 13:08:07 UTC (rev 2760)
+++ trunk/doc/plugins.dox	2008-07-07 16:16:18 UTC (rev 2761)
@@ -166,7 +166,9 @@
  *  @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.

Modified: trunk/plugins/autosave.c
===================================================================
--- trunk/plugins/autosave.c	2008-07-07 13:08:07 UTC (rev 2760)
+++ trunk/plugins/autosave.c	2008-07-07 16:16:18 UTC (rev 2761)
@@ -54,7 +54,7 @@
 {
 	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 @@
 {
 	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);

Modified: trunk/plugins/classbuilder.c
===================================================================
--- trunk/plugins/classbuilder.c	2008-07-07 13:08:07 UTC (rev 2760)
+++ trunk/plugins/classbuilder.c	2008-07-07 16:16:18 UTC (rev 2761)
@@ -355,7 +355,7 @@
 	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 @@
 	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);

Modified: trunk/plugins/demoplugin.c
===================================================================
--- trunk/plugins/demoplugin.c	2008-07-07 13:08:07 UTC (rev 2760)
+++ trunk/plugins/demoplugin.c	2008-07-07 16:16:18 UTC (rev 2761)
@@ -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 @@
 	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 @@
 	/* 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 @@
 		/* 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 */
 	}
 }
 

Modified: trunk/plugins/export.c
===================================================================
--- trunk/plugins/export.c	2008-07-07 13:08:07 UTC (rev 2760)
+++ trunk/plugins/export.c	2008-07-07 16:16:18 UTC (rev 2761)
@@ -163,14 +163,14 @@
 		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 @@
 	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 @@
 	}
 	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 @@
 			}
 			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 @@
 	}
 
 	/* 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 @@
 			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 @@
 	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);

Modified: trunk/plugins/filebrowser.c
===================================================================
--- trunk/plugins/filebrowser.c	2008-07-07 13:08:07 UTC (rev 2760)
+++ trunk/plugins/filebrowser.c	2008-07-07 16:16:18 UTC (rev 2761)
@@ -261,6 +261,7 @@
 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 @@
 	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 @@
 {
 	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 @@
 	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 @@
 	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();

Modified: trunk/plugins/htmlchars.c
===================================================================
--- trunk/plugins/htmlchars.c	2008-07-07 13:08:07 UTC (rev 2760)
+++ trunk/plugins/htmlchars.c	2008-07-07 16:16:18 UTC (rev 2761)
@@ -85,7 +85,7 @@
 		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 @@
 	/* 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 */

Modified: trunk/plugins/pluginmacros.h
===================================================================
--- trunk/plugins/pluginmacros.h	2008-07-07 13:08:07 UTC (rev 2760)
+++ trunk/plugins/pluginmacros.h	2008-07-07 16:16:18 UTC (rev 2761)
@@ -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 */
-#define p_editor		geany_functions->p_editor		/**< See editor.h */
 
-
-#ifdef GEANY_DISABLE_DEPRECATED
-
+/* function group macros */
+#define p_editor		geany_functions->p_editor		/**< See editor.h */
+#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

Modified: trunk/plugins/vcdiff.c
===================================================================
--- trunk/plugins/vcdiff.c	2008-07-07 13:08:07 UTC (rev 2760)
+++ trunk/plugins/vcdiff.c	2008-07-07 16:16:18 UTC (rev 2761)
@@ -39,7 +39,9 @@
 #include "ui_utils.h"
 #include "pluginmacros.h"
 
+#define project	geany->app->project
 
+
 PluginFields	*plugin_fields;
 GeanyData		*geany_data;
 GeanyFunctions	*geany_functions;
@@ -283,7 +285,7 @@
 		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 @@
 	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);

Modified: trunk/src/plugindata.h
===================================================================
--- trunk/src/plugindata.h	2008-07-07 13:08:07 UTC (rev 2760)
+++ trunk/src/plugindata.h	2008-07-07 16:16:18 UTC (rev 2761)
@@ -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 @@
 /* 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)


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list