SF.net SVN: geany: [1974] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Wed Oct 24 12:04:16 UTC 2007
Revision: 1974
http://geany.svn.sourceforge.net/geany/?rev=1974&view=rev
Author: ntrel
Date: 2007-10-24 05:04:15 -0700 (Wed, 24 Oct 2007)
Log Message:
-----------
Add pluginmacros.h to define common macros for app, utils, etc.
Add more documentation/comments to demoplugin.c.
Modified Paths:
--------------
trunk/ChangeLog
trunk/plugins/Makefile.am
trunk/plugins/demoplugin.c
trunk/plugins/filebrowser.c
Added Paths:
-----------
trunk/plugins/pluginmacros.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-10-24 11:15:00 UTC (rev 1973)
+++ trunk/ChangeLog 2007-10-24 12:04:15 UTC (rev 1974)
@@ -15,6 +15,10 @@
Separate toolbar code from init().
* plugins/filebrowser.c:
Add 'Show hidden files' checkbox in the popup menu.
+ * plugins/demoplugin.c, plugins/filebrowser.c, plugins/Makefile.am,
+ plugins/pluginmacros.h:
+ Add pluginmacros.h to define common macros for app, utils, etc.
+ Add more documentation/comments to demoplugin.c.
2007-10-23 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/plugins/Makefile.am
===================================================================
--- trunk/plugins/Makefile.am 2007-10-24 11:15:00 UTC (rev 1973)
+++ trunk/plugins/Makefile.am 2007-10-24 12:04:15 UTC (rev 1974)
@@ -1,7 +1,8 @@
# Adapted from Pidgin's plugins/Makefile.am, thanks
EXTRA_DIST = \
- makefile.win32
+ makefile.win32 \
+ pluginmacros.h
plugindir = $(libdir)/geany
Modified: trunk/plugins/demoplugin.c
===================================================================
--- trunk/plugins/demoplugin.c 2007-10-24 11:15:00 UTC (rev 1973)
+++ trunk/plugins/demoplugin.c 2007-10-24 12:04:15 UTC (rev 1974)
@@ -22,33 +22,47 @@
* $Id$
*/
-/* Demo plugin. */
+/**
+ * Demo plugin - example of a basic plugin for Geany. Adds a menu item to the
+ * Tools menu.
+ *
+ * Note: This is not installed by default, but (on *nix) you can build it as follows:
+ * cd plugins
+ * make demoplugin.so
+ *
+ * Then copy or symlink the plugins/demoplugin.so file to ~/.geany/plugins
+ * - it will be loaded at next startup.
+ */
-#include "geany.h"
-#include "support.h"
-#include "plugindata.h"
+#include "geany.h" // for the GeanyApp data type
+#include "support.h" // for the _() translation macro (see also po/POTFILES.in)
+#include "plugindata.h" // this defines the plugin API
+#include "pluginmacros.h" // some useful macros to avoid typing geany_data so often
+
+
+/* These items are set by Geany before init() is called. */
PluginFields *plugin_fields;
GeanyData *geany_data;
-/* Check that Geany supports plugin API version 2 or later, and check
+/* Check that Geany supports plugin API version 7 or later, and check
* for binary compatibility. */
VERSION_CHECK(7)
-/* All plugins must set name, description and version */
+/* All plugins must set name, description and version. */
PLUGIN_INFO(_("Demo"), _("Example plugin."), "0.1")
-/* Callback when the menu item is clicked */
+/* Callback when the menu item is clicked. */
static void
item_activate(GtkMenuItem *menuitem, gpointer gdata)
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new(
- GTK_WINDOW(geany_data->app->window),
+ GTK_WINDOW(app->window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
@@ -61,7 +75,8 @@
}
-/* Called by Geany to initialize the plugin */
+/* Called by Geany to initialize the plugin.
+ * Note: data is the same as geany_data. */
void init(GeanyData *data)
{
GtkWidget *demo_item;
@@ -78,7 +93,7 @@
/* Called by Geany before unloading the plugin.
- * Here any UI changes should be removed, memory freed and any other finalization done */
+ * Here any UI changes should be removed, memory freed and any other finalization done. */
void cleanup()
{
// remove the menu item added in init()
Modified: trunk/plugins/filebrowser.c
===================================================================
--- trunk/plugins/filebrowser.c 2007-10-24 11:15:00 UTC (rev 1973)
+++ trunk/plugins/filebrowser.c 2007-10-24 12:04:15 UTC (rev 1974)
@@ -33,7 +33,9 @@
#include "document.h"
#include "utils.h"
#include "keybindings.h"
+
#include "plugindata.h"
+#include "pluginmacros.h"
PluginFields *plugin_fields;
@@ -45,14 +47,6 @@
PLUGIN_INFO(_("File Browser"), _("Adds a file browser tab to the sidebar."), "0.1")
-#define doc_array geany_data->doc_array
-#define documents geany_data->document
-#define utils geany_data->utils
-#define ui geany_data->ui
-#define support geany_data->support
-#define tm geany_data->tm
-
-
enum
{
FILEVIEW_COLUMN_ICON = 0,
@@ -310,7 +304,7 @@
gtk_widget_show(item);
gtk_container_add(GTK_CONTAINER(menu), item);
g_signal_connect_swapped((gpointer) item, "activate",
- G_CALLBACK(geany_data->keybindings->send_command),
+ G_CALLBACK(keybindings->send_command),
GINT_TO_POINTER(GEANY_KEYS_MENU_SIDEBAR));
return menu;
@@ -391,7 +385,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->prefs->tagbar_font);
+ pfd = pango_font_description_from_string(prefs->tagbar_font);
gtk_widget_modify_font(file_view, pfd);
pango_font_description_free(pfd);
@@ -411,7 +405,7 @@
{
GtkWidget *wid, *toolbar;
GtkTooltips *tooltips = GTK_TOOLTIPS(support->lookup_widget(
- geany_data->app->window, "tooltips"));
+ app->window, "tooltips"));
toolbar = gtk_toolbar_new();
gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar), GTK_ICON_SIZE_MENU);
@@ -467,7 +461,7 @@
gtk_container_add(GTK_CONTAINER(vbox), scrollwin);
gtk_widget_show_all(vbox);
- gtk_notebook_append_page(GTK_NOTEBOOK(data->app->treeview_notebook), vbox,
+ gtk_notebook_append_page(GTK_NOTEBOOK(app->treeview_notebook), vbox,
gtk_label_new(_("Files")));
}
Added: trunk/plugins/pluginmacros.h
===================================================================
--- trunk/plugins/pluginmacros.h (rev 0)
+++ trunk/plugins/pluginmacros.h 2007-10-24 12:04:15 UTC (rev 1974)
@@ -0,0 +1,46 @@
+/*
+ * pluginmacros.h - this file is part of Geany, a fast and lightweight IDE
+ *
+ * Copyright 2007 Enrico Tröger <enrico.troeger at uvena.de>
+ * Copyright 2007 Nick Treleaven <nick.treleaven at btinternet.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$
+ */
+
+/* Useful macros to avoid typing geany_data so often. */
+
+#ifndef PLUGINMACROS_H
+#define PLUGINMACROS_H
+
+#define app geany_data->app
+#define doc_array geany_data->doc_array
+#define prefs geany_data->prefs
+
+#define dialogs geany_data->dialogs
+#define documents geany_data->document
+#define encoding geany_data->encoding
+#define keybindings geany_data->keybindings
+#define msgwindow geany_data->msgwindow
+#define scintilla geany_data->sci
+#define support geany_data->support
+#define templates geany_data->templates
+#define tm geany_data->tm
+#define ui geany_data->ui
+#define utils geany_data->utils
+
+#endif
Property changes on: trunk/plugins/pluginmacros.h
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
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