SF.net SVN: geany:[3966] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Tue Jul 14 15:06:20 UTC 2009


Revision: 3966
          http://geany.svn.sourceforge.net/geany/?rev=3966&view=rev
Author:   ntrel
Date:     2009-07-14 15:06:20 +0000 (Tue, 14 Jul 2009)

Log Message:
-----------
Add geanyplugin.h single include for plugin API; update all core
plugins to use it.
Add sci_set_font() to API.
Update plugin howto.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/doc/Doxyfile.in
    trunk/doc/plugins.dox
    trunk/plugins/Makefile.am
    trunk/plugins/classbuilder.c
    trunk/plugins/demoplugin.c
    trunk/plugins/export.c
    trunk/plugins/filebrowser.c
    trunk/plugins/geanyfunctions.h
    trunk/plugins/htmlchars.c
    trunk/plugins/saveactions.c
    trunk/plugins/splitwindow.c
    trunk/src/plugindata.h
    trunk/src/plugins.c
    trunk/wscript

Added Paths:
-----------
    trunk/plugins/geanyplugin.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-07-14 13:26:19 UTC (rev 3965)
+++ trunk/ChangeLog	2009-07-14 15:06:20 UTC (rev 3966)
@@ -15,6 +15,15 @@
    Add documents_foreach() API macro that skips invalid docs.
    Make filetypes[], documents[] part of the API again.
    Add GEANY() macro for sharing geany symbols between API and core.
+ * src/plugindata.h, src/plugins.c, doc/plugins.dox,
+   plugins/saveactions.c, plugins/export.c, plugins/geanyfunctions.h,
+   plugins/demoplugin.c, plugins/filebrowser.c, plugins/splitwindow.c,
+   plugins/htmlchars.c, plugins/geanyplugin.h, plugins/Makefile.am,
+   plugins/classbuilder.c, wscript:
+   Add geanyplugin.h single include for plugin API; update all core
+   plugins to use it.
+   Add sci_set_font() to API.
+   Update plugin howto.
 
 
 2009-07-13  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: trunk/doc/Doxyfile.in
===================================================================
--- trunk/doc/Doxyfile.in	2009-07-14 13:26:19 UTC (rev 3965)
+++ trunk/doc/Doxyfile.in	2009-07-14 15:06:20 UTC (rev 3966)
@@ -94,7 +94,7 @@
 #---------------------------------------------------------------------------
 # configuration options related to the input files
 #---------------------------------------------------------------------------
-INPUT                  = ../src/ ./ ../plugins/pluginmacros.h \
+INPUT                  = ../src/ ./ ../plugins/pluginmacros.h ../plugins/geanyplugin.h \
                          ../tagmanager/tm_source_file.c ../tagmanager/include/tm_source_file.h \
                          ../tagmanager/tm_work_object.c ../tagmanager/include/tm_work_object.h \
                          ../tagmanager/tm_workspace.c ../tagmanager/include/tm_workspace.h

Modified: trunk/doc/plugins.dox
===================================================================
--- trunk/doc/plugins.dox	2009-07-14 13:26:19 UTC (rev 3965)
+++ trunk/doc/plugins.dox	2009-07-14 15:06:20 UTC (rev 3966)
@@ -365,23 +365,16 @@
  *
  *  Let's start with the very basic headers and add more later if necessary.
  *  @code
-#include "geany.h"
-#include "plugindata.h"
-#include "geanyfunctions.h"
+#include "geanyplugin.h"
  *  @endcode
  *
- *  @a geany.h will include the necessary GTK header files, so there is no need to include
- *  @a gtk/gtk.h yourself.
+ *  @a geanyplugin.h includes all of the Geany API and also the necessary GTK header files,
+ *  so there is no need to include @a gtk/gtk.h yourself.
  *
+ *  @note
  *  @a plugindata.h contains the biggest part of the plugin API and provides some basic macros.
+ *  @a geanyfunctions.h provides some macros for convenient access to plugin API functions.
  *
- *  @a geanyfunctions.h provide some macros for convenient access to the plugin API.
- *
- *  Later, you will note that by adding more functionality more header file includes will be
- *  necessary. Best practice for including header files is to always include @a geany.h at first,
- *  then include other necessary header files and at last include plugindata.h and @a
- *  geanyfunctions.h.
- *
  *  The you should define three basic variables which will give access to data fields and
  *  functions provided by the plugin API.
  *  @code
@@ -400,14 +393,14 @@
  *  Nevertheless when setting this value, you should choose the lowest possible version here to
  *  make the plugin compatible with a bigger number of versions of Geany.
  *
- *  As the next step, you will need to tell Geany a couple of basic information of your plugin,
- *  so it is able to show them e.g. on the plugin manager dialog.
+ *  For the next step, you will need to tell Geany some basic information about your plugin
+ *  which will be shown in the plugin manager dialog.
  *
  *  For doing this, you should use PLUGIN_SET_INFO() which expects 4 values:
- *  - Plugin name that should appear on the plugin manager dialog
- *  - Short plugin description
- *  - Plugin version
- *  - Author.
+ *  - Plugin name
+ *  - Short description
+ *  - Version
+ *  - Author
  *
  *  Based on this, the line could look like:
  *  @code
@@ -421,7 +414,7 @@
  *  need to implement the function that is called when your plugin is unloaded.
  *  These functions are called plugin_init() and plugin_cleanup(). Let's see how it could look like:
  *  @code
-PLUGIN_VERSION_CHECK(130)
+PLUGIN_VERSION_CHECK(147)
 
 PLUGIN_SET_INFO("HelloWorld", "Just another tool to say hello world",
 				"1.0", "Joe Doe <joe.doe at example.org>");
@@ -435,15 +428,15 @@
 }
  *  @endcode
  *
- *  If you think this plugin seems to doesn't implement any function right now and only waste
- *  some memory, you are right. At least, it should compile and load/unload on in Geany nicely.
+ *  If you think this plugin seems not to implement any functionality right now and only wastes
+ *  some memory, you are right. But it should compile and load/unload in Geany nicely.
  *  Now you have the very basic layout of a new plugin. Great, isn't it?
  *
  *  Let's go on and implement some real functionality.
  *
  *  As mentioned before, plugin_init() will be called when the plugin is loaded in Geany.
- *  So it should implement everything that needs to be done during startup. In this example case,
- *  we like to add a menu item to Geany's Tools menu which runs a dialog printing "Hello World".
+ *  So it should implement everything that needs to be done during startup. In this case,
+ *  we'd like to add a menu item to Geany's Tools menu which runs a dialog printing "Hello World".
  *  @code
 void plugin_init(GeanyData *data)
 {
@@ -467,15 +460,11 @@
  *  This will add an item to the Tools menu and connect this item to a function which implements
  *  what should be done when the menu item is activated by the user.
  *  This is done by g_signal_connect(). The Tools menu can be accessed with
- *  geany->main_widgets->tools_menu. The structure @a main_widgets contains pointers to some
- *  main GUI elements in Geany. To be able to use it, you must include ui_utils.h. This can
- *  be done by adding the following line to the include section of your code.
- *  @code
-#include "ui_utils.h"
- *  @endcode
+ *  geany->main_widgets->tools_menu. The structure @a main_widgets contains pointers to the
+ *  main GUI elements in Geany.
  *
- *  Geany is offering a simple API for showing message dialogs. So the function contains
- *  only a few lines like:
+ *  Geany has a simple API for showing message dialogs. So our function contains
+ *  only a few lines:
  *  @code
 void item_activate_cb(GtkMenuItem *menuitem, gpointer user_data)
 {
@@ -485,8 +474,7 @@
  *
  *  For the moment you don't need to worry about the parameters of that function.
  *
- *  Do you remember, you need to clean up when unloading the plugin? Because of this,
- *  some more action is required.
+ *  Now we need to clean up properly when the plugin is unloaded.
  *
  *  To remove the menu item from the Tools menu, you can use gtk_widget_destroy().
  *  gtk_widget_destroy() expects a pointer to a GtkWidget object.
@@ -513,22 +501,19 @@
 }
  *  @endcode
  *
- *  This will ensure, your menu item will be removed from the Tools menu as well as from
- *  memory once your plugin is unloaded and you don't leave any memory leaks back.
+ *  This will ensure your menu item is removed from the Tools menu as well as from
+ *  memory once your plugin is unloaded, so you don't leave any memory leaks.
  *  Once this is done, your first plugin is ready. Congratulations!
  *
  *  The complete listing (without comments):
  *  @code
-#include "geany.h"
-#include "ui_utils.h"
-#include "plugindata.h"
-#include "geanyfunctions.h"
+#include "geanyplugin.h"
 
 GeanyPlugin		*geany_plugin;
 GeanyData		*geany_data;
 GeanyFunctions	*geany_functions;
 
-PLUGIN_VERSION_CHECK(130)
+PLUGIN_VERSION_CHECK(147)
 
 PLUGIN_SET_INFO("HelloWorld", "Just another tool to say hello world",
 				"1.0", "John Doe <john.doe at example.org>");
@@ -557,4 +542,7 @@
 }
  *  @endcode
  *
+ *
+ * Now you might like to look at Geany's source code for core plugins such as
+ * @a plugins/demoplugin.c.
  **/

Modified: trunk/plugins/Makefile.am
===================================================================
--- trunk/plugins/Makefile.am	2009-07-14 13:26:19 UTC (rev 3965)
+++ trunk/plugins/Makefile.am	2009-07-14 15:06:20 UTC (rev 3966)
@@ -2,8 +2,6 @@
 
 EXTRA_DIST = \
 	makefile.win32 \
-	pluginmacros.h \
-	geanyfunctions.h \
 	genapi.py
 
 plugindir = $(libdir)/geany
@@ -11,6 +9,7 @@
 plugins_includedir = $(includedir)/geany
 plugins_include_HEADERS = \
 	pluginmacros.h \
+	geanyplugin.h \
 	geanyfunctions.h
 
 # systems without python should continue to build OK

Modified: trunk/plugins/classbuilder.c
===================================================================
--- trunk/plugins/classbuilder.c	2009-07-14 13:26:19 UTC (rev 3965)
+++ trunk/plugins/classbuilder.c	2009-07-14 15:06:20 UTC (rev 3966)
@@ -25,14 +25,7 @@
 
 /* Class Builder - creates source files containing a new class interface and definition. */
 
-#include "geany.h"
-#include "plugindata.h"
-#include "support.h"
-#include "filetypes.h"
-#include "document.h"
-#include "editor.h"
-#include "ui_utils.h"
-#include "geanyfunctions.h"
+#include "geanyplugin.h"
 
 
 GeanyData		*geany_data;
@@ -197,7 +190,7 @@
 
 /* The list must be ended with NULL as an extra check that arg_count is correct. */
 static void
-utils_free_pointers(gsize arg_count, ...)
+free_pointers(gsize arg_count, ...)
 {
 	va_list a;
 	gsize i;
@@ -716,7 +709,7 @@
 		g_free(text);
 	}
 
-	utils_free_pointers(17, tmp, class_info->class_name, class_info->class_name_up,
+	free_pointers(17, tmp, class_info->class_name, class_info->class_name_up,
 		class_info->base_name, class_info->class_name_low, class_info->base_include,
 		class_info->header, class_info->header_guard, class_info->source, class_info->base_decl,
 		class_info->constructor_decl, class_info->constructor_impl,

Modified: trunk/plugins/demoplugin.c
===================================================================
--- trunk/plugins/demoplugin.c	2009-07-14 13:26:19 UTC (rev 3965)
+++ trunk/plugins/demoplugin.c	2009-07-14 15:06:20 UTC (rev 3966)
@@ -35,28 +35,19 @@
  */
 
 
-#include "geany.h"		/* for the GeanyApp data type */
-#include "support.h"	/* for the _() translation macro (see also po/POTFILES.in) */
-#include "editor.h"		/* for the declaration of the GeanyEditor struct, not strictly necessary
-						   as it will be also included by plugindata.h */
-#include "document.h"	/* for the declaration of the GeanyDocument struct */
-#include "ui_utils.h"
+#include "geanyplugin.h"	/* plugin API, always comes first */
 #include "Scintilla.h"	/* for the SCNotification struct */
 
-#include "plugindata.h"		/* this defines the plugin API */
-#include "geanyfunctions.h"	/* this wraps geany_functions function pointers */
 
-
-
 /* These items are set by Geany before plugin_init() is called. */
 GeanyPlugin		*geany_plugin;
 GeanyData		*geany_data;
 GeanyFunctions	*geany_functions;
 
 
-/* Check that the running Geany supports the plugin API used below, and check
+/* Check that the running Geany supports the plugin API version used below, and check
  * for binary compatibility. */
-PLUGIN_VERSION_CHECK(112)
+PLUGIN_VERSION_CHECK(147)
 
 /* All plugins must set name, description, version and author. */
 PLUGIN_SET_INFO(_("Demo"), _("Example plugin."), VERSION, _("The Geany developer team"))

Modified: trunk/plugins/export.c
===================================================================
--- trunk/plugins/export.c	2009-07-14 13:26:19 UTC (rev 3965)
+++ trunk/plugins/export.c	2009-07-14 15:06:20 UTC (rev 3966)
@@ -27,15 +27,7 @@
 #include <ctype.h>
 #include <math.h>
 
-#include "geany.h"
-#include "support.h"
-#include "plugindata.h"
-#include "editor.h"
-#include "document.h"
-#include "prefs.h"
-#include "utils.h"
-#include "ui_utils.h"
-#include "geanyfunctions.h"
+#include "geanyplugin.h"
 
 
 GeanyData		*geany_data;

Modified: trunk/plugins/filebrowser.c
===================================================================
--- trunk/plugins/filebrowser.c	2009-07-14 13:26:19 UTC (rev 3965)
+++ trunk/plugins/filebrowser.c	2009-07-14 15:06:20 UTC (rev 3966)
@@ -24,23 +24,12 @@
 
 /* Sidebar file browser plugin. */
 
-#include "geany.h"
+#include "geanyplugin.h"
 #include <string.h>
 
 #include <gdk/gdkkeysyms.h>
 
-#include "support.h"
-#include "prefs.h"
-#include "document.h"
-#include "utils.h"
-#include "keybindings.h"
-#include "project.h"
-#include "ui_utils.h"
 
-#include "plugindata.h"
-#include "geanyfunctions.h"
-
-
 GeanyData		*geany_data;
 GeanyFunctions	*geany_functions;
 

Modified: trunk/plugins/geanyfunctions.h
===================================================================
--- trunk/plugins/geanyfunctions.h	2009-07-14 13:26:19 UTC (rev 3965)
+++ trunk/plugins/geanyfunctions.h	2009-07-14 15:06:20 UTC (rev 3966)
@@ -148,6 +148,8 @@
 	geany_functions->p_sci->get_contents_range
 #define sci_get_selection_contents \
 	geany_functions->p_sci->get_selection_contents
+#define sci_set_font \
+	geany_functions->p_sci->set_font
 #define templates_get_template_fileheader \
 	geany_functions->p_templates->get_template_fileheader
 #define utils_str_equal \

Added: trunk/plugins/geanyplugin.h
===================================================================
--- trunk/plugins/geanyplugin.h	                        (rev 0)
+++ trunk/plugins/geanyplugin.h	2009-07-14 15:06:20 UTC (rev 3966)
@@ -0,0 +1,59 @@
+/*
+ *      geanyplugin.h - this file is part of Geany, a fast and lightweight IDE
+ *
+ *      Copyright 2009 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+ *      Copyright 2009 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
+ *
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2 of the License, or
+ *      (at your option) any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ *      MA 02110-1301, USA.
+ *
+ * $Id$
+ */
+
+/**
+ *  @file geanyplugin.h
+ *  Single include for plugins.
+ **/
+
+
+#ifndef GEANY_PLUGIN_H
+#define GEANY_PLUGIN_H 1
+
+#include "geany.h"
+#include "plugindata.h"
+
+#include "dialogs.h"
+#include "document.h"
+#include "editor.h"
+#include "encodings.h"
+#include "filetypes.h"
+#include "highlighting.h"
+#include "keybindings.h"
+#include "main.h"
+#include "msgwindow.h"
+#include "plugins.h"
+#include "prefs.h"
+#include "project.h"
+#include "sciwrappers.h"
+#include "search.h"
+#include "support.h"
+#include "templates.h"
+#include "toolbar.h"
+#include "ui_utils.h"
+#include "utils.h"
+
+#include "geanyfunctions.h"
+
+#endif


Property changes on: trunk/plugins/geanyplugin.h
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Modified: trunk/plugins/htmlchars.c
===================================================================
--- trunk/plugins/htmlchars.c	2009-07-14 13:26:19 UTC (rev 3965)
+++ trunk/plugins/htmlchars.c	2009-07-14 15:06:20 UTC (rev 3966)
@@ -25,19 +25,10 @@
 
 /* HTML Characters plugin (Inserts HTML character entities like '&') */
 
-#include "geany.h"
+#include "geanyplugin.h"
 #include <string.h>
 
-#include "support.h"
-#include "plugindata.h"
-#include "document.h"
-#include "editor.h"
-#include "keybindings.h"
-#include "ui_utils.h"
-#include "utils.h"
-#include "geanyfunctions.h"
 
-
 GeanyData		*geany_data;
 GeanyFunctions	*geany_functions;
 

Modified: trunk/plugins/saveactions.c
===================================================================
--- trunk/plugins/saveactions.c	2009-07-14 13:26:19 UTC (rev 3965)
+++ trunk/plugins/saveactions.c	2009-07-14 15:06:20 UTC (rev 3966)
@@ -23,16 +23,8 @@
  */
 
 
-#include "geany.h"
-#include "support.h"
-#include "document.h"
-#include "utils.h"
-#include "ui_utils.h"
-#include "filetypes.h"
+#include "geanyplugin.h"
 
-#include "plugindata.h"
-#include "geanyfunctions.h"
-
 #include <unistd.h>
 #include <errno.h>
 #include <glib/gstdio.h>
@@ -353,7 +345,7 @@
 		config, "saveactions", "enable_backupcopy", FALSE);
 
 	instantsave_default_ft = utils_get_setting_string(config, "instantsave", "default_ft",
-		filetypes_index(GEANY_FILETYPES_NONE)->name);
+		filetypes[GEANY_FILETYPES_NONE]->name);
 
 	autosave_src_id = G_MAXUINT; /* mark as invalid */
 	autosave_interval = utils_get_setting_integer(config, "autosave", "interval", 300);

Modified: trunk/plugins/splitwindow.c
===================================================================
--- trunk/plugins/splitwindow.c	2009-07-14 13:26:19 UTC (rev 3965)
+++ trunk/plugins/splitwindow.c	2009-07-14 15:06:20 UTC (rev 3966)
@@ -24,24 +24,14 @@
 
 /* Split Window plugin. */
 
-#include "geany.h"
+#include "geanyplugin.h"
 #include <string.h>
 
-#include "support.h"
 #include "Scintilla.h"
 #include "ScintillaWidget.h"
 #include "SciLexer.h"
 
-#include "ui_utils.h"
-#include "document.h"
-#include "editor.h"
-#include "plugindata.h"
-#include "keybindings.h"
-#include "utils.h"
 
-#include "geanyfunctions.h"
-
-
 PLUGIN_VERSION_CHECK(GEANY_API_VERSION)
 PLUGIN_SET_INFO(_("Split Window"), _("Splits the editor view into two windows."),
 	VERSION, _("The Geany developer team"))
@@ -124,14 +114,6 @@
 }
 
 
-static void sci_set_font(ScintillaObject *sci, gint style, const gchar *font,
-	gint size)
-{
-	scintilla_send_message(sci, SCI_STYLESETFONT, style, (sptr_t) font);
-	scintilla_send_message(sci, SCI_STYLESETSIZE, style, size);
-}
-
-
 static void update_font(ScintillaObject *current, ScintillaObject *sci)
 {
 	gint style_id;

Modified: trunk/src/plugindata.h
===================================================================
--- trunk/src/plugindata.h	2009-07-14 13:26:19 UTC (rev 3965)
+++ trunk/src/plugindata.h	2009-07-14 15:06:20 UTC (rev 3966)
@@ -50,7 +50,7 @@
 enum {
 	/** The Application Programming Interface (API) version, incremented
 	 * whenever any plugin data types are modified or appended to. */
-	GEANY_API_VERSION = 146,
+	GEANY_API_VERSION = 147,
 
 	/** The Application Binary Interface (ABI) version, incremented whenever
 	 * existing fields in the plugin data types have to be changed or reordered. */
@@ -326,6 +326,7 @@
 	gchar*	(*get_contents) (struct _ScintillaObject *sci, gint len);
 	gchar*	(*get_contents_range) (struct _ScintillaObject *sci, gint start, gint end);
 	gchar*	(*get_selection_contents) (struct _ScintillaObject *sci);
+	void	(*set_font) (struct _ScintillaObject *sci, gint style, const gchar *font, gint size);
 }
 SciFuncs;
 

Modified: trunk/src/plugins.c
===================================================================
--- trunk/src/plugins.c	2009-07-14 13:26:19 UTC (rev 3965)
+++ trunk/src/plugins.c	2009-07-14 15:06:20 UTC (rev 3966)
@@ -195,7 +195,8 @@
 	&sci_indicator_set,
 	&sci_get_contents,
 	&sci_get_contents_range,
-	&sci_get_selection_contents
+	&sci_get_selection_contents,
+	&sci_set_font
 };
 
 static TemplateFuncs template_funcs = {

Modified: trunk/wscript
===================================================================
--- trunk/wscript	2009-07-14 13:26:19 UTC (rev 3965)
+++ trunk/wscript	2009-07-14 15:06:20 UTC (rev 3966)
@@ -453,7 +453,7 @@
 			src/highlighting.h src/keybindings.h src/main.h src/msgwindow.h src/plugindata.h
 			src/plugins.h src/prefs.h src/project.h src/sciwrappers.h src/search.h src/support.h
 			src/templates.h src/toolbar.h src/ui_utils.h src/utils.h plugins/pluginmacros.h
-			plugins/geanyfunctions.h ''')
+			plugins/geanyplugin.h plugins/geanyfunctions.h ''')
 		bld.install_files('${PREFIX}/include/geany/scintilla', '''
 			scintilla/include/SciLexer.h scintilla/include/Scintilla.h
 			scintilla/include/Scintilla.iface scintilla/include/ScintillaWidget.h ''')


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