Kaydet (Commit) 94fbc4ba authored tarafından Nick Treleaven's avatar Nick Treleaven

Add pluginmacros.h to define common macros for app, utils, etc.

Add more documentation/comments to demoplugin.c.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1974 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 58243ee3
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
Separate toolbar code from init(). Separate toolbar code from init().
* plugins/filebrowser.c: * plugins/filebrowser.c:
Add 'Show hidden files' checkbox in the popup menu. 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> 2007-10-23 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
......
# Adapted from Pidgin's plugins/Makefile.am, thanks # Adapted from Pidgin's plugins/Makefile.am, thanks
EXTRA_DIST = \ EXTRA_DIST = \
makefile.win32 makefile.win32 \
pluginmacros.h
plugindir = $(libdir)/geany plugindir = $(libdir)/geany
......
...@@ -22,33 +22,47 @@ ...@@ -22,33 +22,47 @@
* $Id$ * $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" // for the GeanyApp data type
#include "support.h" // for the _() translation macro (see also po/POTFILES.in)
#include "geany.h" #include "plugindata.h" // this defines the plugin API
#include "support.h" #include "pluginmacros.h" // some useful macros to avoid typing geany_data so often
#include "plugindata.h"
/* These items are set by Geany before init() is called. */
PluginFields *plugin_fields; PluginFields *plugin_fields;
GeanyData *geany_data; 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. */ * for binary compatibility. */
VERSION_CHECK(7) 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") PLUGIN_INFO(_("Demo"), _("Example plugin."), "0.1")
/* Callback when the menu item is clicked */ /* Callback when the menu item is clicked. */
static void static void
item_activate(GtkMenuItem *menuitem, gpointer gdata) item_activate(GtkMenuItem *menuitem, gpointer gdata)
{ {
GtkWidget *dialog; GtkWidget *dialog;
dialog = gtk_message_dialog_new( dialog = gtk_message_dialog_new(
GTK_WINDOW(geany_data->app->window), GTK_WINDOW(app->window),
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO, GTK_MESSAGE_INFO,
GTK_BUTTONS_OK, GTK_BUTTONS_OK,
...@@ -61,7 +75,8 @@ item_activate(GtkMenuItem *menuitem, gpointer gdata) ...@@ -61,7 +75,8 @@ item_activate(GtkMenuItem *menuitem, gpointer gdata)
} }
/* 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) void init(GeanyData *data)
{ {
GtkWidget *demo_item; GtkWidget *demo_item;
...@@ -78,7 +93,7 @@ void init(GeanyData *data) ...@@ -78,7 +93,7 @@ void init(GeanyData *data)
/* Called by Geany before unloading the plugin. /* 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() void cleanup()
{ {
// remove the menu item added in init() // remove the menu item added in init()
......
...@@ -33,7 +33,9 @@ ...@@ -33,7 +33,9 @@
#include "document.h" #include "document.h"
#include "utils.h" #include "utils.h"
#include "keybindings.h" #include "keybindings.h"
#include "plugindata.h" #include "plugindata.h"
#include "pluginmacros.h"
PluginFields *plugin_fields; PluginFields *plugin_fields;
...@@ -45,14 +47,6 @@ VERSION_CHECK(26) ...@@ -45,14 +47,6 @@ VERSION_CHECK(26)
PLUGIN_INFO(_("File Browser"), _("Adds a file browser tab to the sidebar."), "0.1") 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 enum
{ {
FILEVIEW_COLUMN_ICON = 0, FILEVIEW_COLUMN_ICON = 0,
...@@ -310,7 +304,7 @@ static GtkWidget *create_popup_menu() ...@@ -310,7 +304,7 @@ static GtkWidget *create_popup_menu()
gtk_widget_show(item); gtk_widget_show(item);
gtk_container_add(GTK_CONTAINER(menu), item); gtk_container_add(GTK_CONTAINER(menu), item);
g_signal_connect_swapped((gpointer) item, "activate", 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)); GINT_TO_POINTER(GEANY_KEYS_MENU_SIDEBAR));
return menu; return menu;
...@@ -391,7 +385,7 @@ static void prepare_file_view() ...@@ -391,7 +385,7 @@ static void prepare_file_view()
gtk_tree_view_set_enable_search(GTK_TREE_VIEW(file_view), TRUE); 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); 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); gtk_widget_modify_font(file_view, pfd);
pango_font_description_free(pfd); pango_font_description_free(pfd);
...@@ -411,7 +405,7 @@ static GtkWidget *make_toolbar() ...@@ -411,7 +405,7 @@ static GtkWidget *make_toolbar()
{ {
GtkWidget *wid, *toolbar; GtkWidget *wid, *toolbar;
GtkTooltips *tooltips = GTK_TOOLTIPS(support->lookup_widget( GtkTooltips *tooltips = GTK_TOOLTIPS(support->lookup_widget(
geany_data->app->window, "tooltips")); app->window, "tooltips"));
toolbar = gtk_toolbar_new(); toolbar = gtk_toolbar_new();
gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar), GTK_ICON_SIZE_MENU); gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar), GTK_ICON_SIZE_MENU);
...@@ -467,7 +461,7 @@ void init(GeanyData *data) ...@@ -467,7 +461,7 @@ void init(GeanyData *data)
gtk_container_add(GTK_CONTAINER(vbox), scrollwin); gtk_container_add(GTK_CONTAINER(vbox), scrollwin);
gtk_widget_show_all(vbox); 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"))); gtk_label_new(_("Files")));
} }
......
/*
* pluginmacros.h - this file is part of Geany, a fast and lightweight IDE
*
* Copyright 2007 Enrico Tröger <enrico.troeger@uvena.de>
* Copyright 2007 Nick Treleaven <nick.treleaven@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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment