Kaydet (Commit) 56fca1b4 authored tarafından Nick Treleaven's avatar Nick Treleaven

Move plugin_* utility functions to pluginutils.c.

Add pluginprivate.h.



git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4035 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 1c3ffe29
2009-07-28 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/pluginprivate.h, src/makefile.win32, src/plugindata.h,
src/pluginutils.c, src/plugins.c, src/pluginutils.h,
src/Makefile.am, ChangeLog, wscript:
Move plugin_* utility functions to pluginutils.c.
Add pluginprivate.h.
2009-07-25 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> 2009-07-25 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* doc/geany.txt, doc/geany.html: * doc/geany.txt, doc/geany.html:
...@@ -7,7 +16,7 @@ ...@@ -7,7 +16,7 @@
2009-07-25 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> 2009-07-25 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
* po/LINGUAS, po/sl_SI.po, THANKS, src/about.c: * po/LINGUAS, po/sl_SI.po, THANKS, src/about.c:
Added a first Slovenian translation. Thanks to Joze Klepec. Added a first Slovenian translation. Thanks to Joze Klepec.
......
...@@ -29,7 +29,9 @@ SRCS = \ ...@@ -29,7 +29,9 @@ SRCS = \
msgwindow.c msgwindow.h \ msgwindow.c msgwindow.h \
navqueue.c navqueue.h \ navqueue.c navqueue.h \
notebook.c notebook.h \ notebook.c notebook.h \
pluginprivate.h \
plugins.c plugins.h \ plugins.c plugins.h \
pluginutils.c pluginutils.h \
prefix.c prefix.h \ prefix.c prefix.h \
prefs.c prefs.h \ prefs.c prefs.h \
printing.c printing.h \ printing.c printing.h \
......
...@@ -62,7 +62,8 @@ endif ...@@ -62,7 +62,8 @@ endif
OBJS = about.o build.o callbacks.o dialogs.o document.o editor.o encodings.o filetypes.o \ OBJS = about.o build.o callbacks.o dialogs.o document.o editor.o encodings.o filetypes.o \
geanyentryaction.o geanymenubuttonaction.o geanyobject.o geanywraplabel.o highlighting.o \ geanyentryaction.o geanymenubuttonaction.o geanyobject.o geanywraplabel.o highlighting.o \
interface.o keybindings.o keyfile.o \ interface.o keybindings.o keyfile.o \
log.o main.o msgwindow.o navqueue.o notebook.o plugins.o prefs.o printing.o project.o \ log.o main.o msgwindow.o navqueue.o notebook.o plugins.o pluginutils.o \
prefs.o printing.o project.o \
queue.o sciwrappers.o search.o socket.o stash.o \ queue.o sciwrappers.o search.o socket.o stash.o \
symbols.o templates.o toolbar.o tools.o treeviews.o \ symbols.o templates.o toolbar.o tools.o treeviews.o \
ui_utils.o utils.o win32.o ui_utils.o utils.o win32.o
......
...@@ -90,7 +90,8 @@ typedef struct PluginInfo ...@@ -90,7 +90,8 @@ typedef struct PluginInfo
PluginInfo; PluginInfo;
/** Basic information for the plugin and identification. */ /** Basic information for the plugin and identification.
* @see geany_plugin. */
typedef struct GeanyPlugin typedef struct GeanyPlugin
{ {
PluginInfo *info; /**< Fields set in plugin_set_info(). */ PluginInfo *info; /**< Fields set in plugin_set_info(). */
......
/*
* pluginprivate.h - this file is part of Geany, a fast and lightweight IDE
*
* Copyright 2009 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* Copyright 2009 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
*
* 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$
*/
#ifndef PLUGINPRIVATE_H
#define PLUGINPRIVATE_H
#include "ui_utils.h"
typedef struct GeanyPluginPrivate
{
GeanyAutoSeparator toolbar_separator;
gboolean resident;
}
GeanyPluginPrivate;
#endif /* PLUGINPRIVATE_H */
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
*/ */
/* Code to manage, load and unload plugins. */ /* Code to manage, load and unload plugins. */
/** @file plugins.c
* Plugin utility functions. */
#include "geany.h" #include "geany.h"
...@@ -61,15 +59,8 @@ ...@@ -61,15 +59,8 @@
#include "stash.h" #include "stash.h"
#include "keyfile.h" #include "keyfile.h"
#include "win32.h" #include "win32.h"
#include "pluginutils.h"
#include "pluginprivate.h"
typedef struct GeanyPluginPrivate
{
GeanyAutoSeparator toolbar_separator;
gboolean resident;
}
GeanyPluginPrivate;
typedef struct Plugin typedef struct Plugin
...@@ -79,7 +70,7 @@ typedef struct Plugin ...@@ -79,7 +70,7 @@ typedef struct Plugin
PluginInfo info; /* plugin name, description, etc */ PluginInfo info; /* plugin name, description, etc */
PluginFields fields; PluginFields fields;
GeanyPlugin public; /* fields the plugin can read */ GeanyPlugin public; /* fields the plugin can read */
GeanyPluginPrivate priv; /* GeanyPlugin type private data */ GeanyPluginPrivate priv; /* GeanyPlugin type private data, same as (*public.priv) */
gulong *signal_ids; /* signal IDs to disconnect when unloading */ gulong *signal_ids; /* signal IDs to disconnect when unloading */
gsize signal_ids_len; gsize signal_ids_len;
...@@ -106,9 +97,6 @@ static GtkWidget *menu_separator = NULL; ...@@ -106,9 +97,6 @@ static GtkWidget *menu_separator = NULL;
static void pm_show_dialog(GtkMenuItem *menuitem, gpointer user_data); static void pm_show_dialog(GtkMenuItem *menuitem, gpointer user_data);
void plugin_add_toolbar_item(GeanyPlugin *plugin, GtkToolItem *item);
void plugin_module_make_resident(GeanyPlugin *plugin);
static PluginFuncs plugin_funcs = { static PluginFuncs plugin_funcs = {
&plugin_add_toolbar_item, &plugin_add_toolbar_item,
...@@ -1307,62 +1295,4 @@ static void pm_show_dialog(GtkMenuItem *menuitem, gpointer user_data) ...@@ -1307,62 +1295,4 @@ static void pm_show_dialog(GtkMenuItem *menuitem, gpointer user_data)
} }
/** Insert a toolbar item before the Quit button, or after the previous plugin toolbar item.
* A separator is added on the first call to this function, and will be shown when @a item is
* shown; hidden when @a item is hidden.
* @note You should still destroy @a item yourself, usually in @ref plugin_cleanup().
* @param plugin Must be @ref geany_plugin.
* @param item The item to add. */
void plugin_add_toolbar_item(GeanyPlugin *plugin, GtkToolItem *item)
{
GtkToolbar *toolbar = GTK_TOOLBAR(main_widgets.toolbar);
gint pos;
GeanyAutoSeparator *autosep;
g_return_if_fail(plugin);
autosep = &plugin->priv->toolbar_separator;
if (!autosep->widget)
{
GtkToolItem *sep;
pos = toolbar_get_insert_position();
sep = gtk_separator_tool_item_new();
gtk_toolbar_insert(toolbar, sep, pos);
autosep->widget = GTK_WIDGET(sep);
gtk_toolbar_insert(toolbar, item, pos + 1);
toolbar_item_ref(sep);
toolbar_item_ref(item);
}
else
{
pos = gtk_toolbar_get_item_index(toolbar, GTK_TOOL_ITEM(autosep->widget));
g_return_if_fail(pos >= 0);
gtk_toolbar_insert(toolbar, item, pos);
toolbar_item_ref(item);
}
/* hide the separator widget if there are no toolbar items showing for the plugin */
ui_auto_separator_add_ref(autosep, GTK_WIDGET(item));
}
/** Ensures that a plugin's module (*.so) will never be unloaded.
* This is necessary if you register new GTypes in your plugin, e.g. when using own classes
* using the GObject system.
*
* @param plugin Must be @ref geany_plugin.
*
* @since 0.16
*/
void plugin_module_make_resident(GeanyPlugin *plugin)
{
g_return_if_fail(plugin);
plugin->priv->resident = TRUE;
}
#endif #endif
/*
* pluginutils.c - this file is part of Geany, a fast and lightweight IDE
*
* Copyright 2009 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* Copyright 2009 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
*
* 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 pluginutils.c
* Plugin utility functions.
* These functions all take the @ref geany_plugin symbol as their first argument. */
#include "geany.h"
#include "pluginutils.h"
#include "pluginprivate.h"
#include "ui_utils.h"
#include "toolbar.h"
/** Insert a toolbar item before the Quit button, or after the previous plugin toolbar item.
* A separator is added on the first call to this function, and will be shown when @a item is
* shown; hidden when @a item is hidden.
* @note You should still destroy @a item yourself, usually in @ref plugin_cleanup().
* @param plugin Must be @ref geany_plugin.
* @param item The item to add. */
void plugin_add_toolbar_item(GeanyPlugin *plugin, GtkToolItem *item)
{
GtkToolbar *toolbar = GTK_TOOLBAR(main_widgets.toolbar);
gint pos;
GeanyAutoSeparator *autosep;
g_return_if_fail(plugin);
autosep = &plugin->priv->toolbar_separator;
if (!autosep->widget)
{
GtkToolItem *sep;
pos = toolbar_get_insert_position();
sep = gtk_separator_tool_item_new();
gtk_toolbar_insert(toolbar, sep, pos);
autosep->widget = GTK_WIDGET(sep);
gtk_toolbar_insert(toolbar, item, pos + 1);
toolbar_item_ref(sep);
toolbar_item_ref(item);
}
else
{
pos = gtk_toolbar_get_item_index(toolbar, GTK_TOOL_ITEM(autosep->widget));
g_return_if_fail(pos >= 0);
gtk_toolbar_insert(toolbar, item, pos);
toolbar_item_ref(item);
}
/* hide the separator widget if there are no toolbar items showing for the plugin */
ui_auto_separator_add_ref(autosep, GTK_WIDGET(item));
}
/** Ensures that a plugin's module (*.so) will never be unloaded.
* This is necessary if you register new GTypes in your plugin, e.g. when using own classes
* using the GObject system.
*
* @param plugin Must be @ref geany_plugin.
*
* @since 0.16
*/
void plugin_module_make_resident(GeanyPlugin *plugin)
{
g_return_if_fail(plugin);
plugin->priv->resident = TRUE;
}
/*
* pluginutils.h - this file is part of Geany, a fast and lightweight IDE
*
* Copyright 2009 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* Copyright 2009 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
*
* 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$
*/
#ifndef PLUGINUTILS_H
#define PLUGINUTILS_H
#include "plugindata.h"
void plugin_add_toolbar_item(GeanyPlugin *plugin, GtkToolItem *item);
void plugin_module_make_resident(GeanyPlugin *plugin);
#endif /* PLUGINUTILS_H */
...@@ -95,7 +95,7 @@ geany_sources = [ ...@@ -95,7 +95,7 @@ geany_sources = [
'src/geanymenubuttonaction.c', 'src/geanyobject.c', 'src/geanywraplabel.c', 'src/geanymenubuttonaction.c', 'src/geanyobject.c', 'src/geanywraplabel.c',
'src/highlighting.c', 'src/interface.c', 'src/keybindings.c', 'src/highlighting.c', 'src/interface.c', 'src/keybindings.c',
'src/keyfile.c', 'src/log.c', 'src/main.c', 'src/msgwindow.c', 'src/navqueue.c', 'src/notebook.c', 'src/keyfile.c', 'src/log.c', 'src/main.c', 'src/msgwindow.c', 'src/navqueue.c', 'src/notebook.c',
'src/plugins.c', 'src/prefix.c', 'src/prefs.c', 'src/printing.c', 'src/project.c', 'src/plugins.c', 'pluginutils.c', 'src/prefix.c', 'src/prefs.c', 'src/printing.c', 'src/project.c',
'src/queue.c', 'src/sciwrappers.c', 'src/search.c', 'src/socket.c', 'src/stash.c', 'src/queue.c', 'src/sciwrappers.c', 'src/search.c', 'src/socket.c', 'src/stash.c',
'src/symbols.c', 'src/symbols.c',
'src/templates.c', 'src/toolbar.c', 'src/tools.c', 'src/treeviews.c', 'src/templates.c', 'src/toolbar.c', 'src/tools.c', 'src/treeviews.c',
......
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