Use ui_add_document_sensitive().
Use PLUGIN_VERSION_CHECK(GEANY_API_VERSION) for internal plugins, except the Demo plugin (as an example). git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3085 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
c343d904b2
commit
51d28d688d
@ -5,6 +5,12 @@
|
||||
Add ui_add_document_sensitive() to the plugin API.
|
||||
Deprecate plugin_fields, PluginFlags - use
|
||||
ui_add_document_sensitive() instead.
|
||||
* plugins/saveactions.c, plugins/export.c, plugins/vcdiff.c,
|
||||
plugins/demoplugin.c, plugins/filebrowser.c, plugins/splitwindow.c,
|
||||
plugins/htmlchars.c, plugins/classbuilder.c:
|
||||
Use ui_add_document_sensitive().
|
||||
Use PLUGIN_VERSION_CHECK(GEANY_API_VERSION) for internal plugins,
|
||||
except the Demo plugin (as an example).
|
||||
|
||||
|
||||
2008-10-13 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
|
||||
|
@ -35,17 +35,19 @@
|
||||
#include "pluginmacros.h"
|
||||
|
||||
|
||||
PluginFields *plugin_fields;
|
||||
GeanyData *geany_data;
|
||||
GeanyFunctions *geany_functions;
|
||||
|
||||
|
||||
PLUGIN_VERSION_CHECK(69)
|
||||
PLUGIN_VERSION_CHECK(GEANY_API_VERSION)
|
||||
|
||||
PLUGIN_SET_INFO(_("Class Builder"), _("Creates source files for new class types."), VERSION,
|
||||
"Alexander Rodin")
|
||||
|
||||
|
||||
static GtkWidget *main_menu_item = NULL;
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
GEANY_CLASS_TYPE_CPP,
|
||||
@ -803,11 +805,12 @@ void plugin_init(GeanyData *data)
|
||||
|
||||
gtk_widget_show_all(menu_create_class1);
|
||||
|
||||
plugin_fields->menu_item = menu_create_class1;
|
||||
p_ui->add_document_sensitive(menu_create_class1);
|
||||
main_menu_item = menu_create_class1;
|
||||
}
|
||||
|
||||
|
||||
void plugin_cleanup(void)
|
||||
{
|
||||
gtk_widget_destroy(plugin_fields->menu_item);
|
||||
gtk_widget_destroy(main_menu_item);
|
||||
}
|
||||
|
@ -45,19 +45,19 @@
|
||||
|
||||
/* These items are set by Geany before plugin_init() is called. */
|
||||
GeanyPlugin *geany_plugin;
|
||||
PluginFields *plugin_fields;
|
||||
GeanyData *geany_data;
|
||||
GeanyFunctions *geany_functions;
|
||||
|
||||
|
||||
/* Check that the running Geany supports the plugin API used below, and check
|
||||
* for binary compatibility. */
|
||||
PLUGIN_VERSION_CHECK(99)
|
||||
PLUGIN_VERSION_CHECK(100)
|
||||
|
||||
/* All plugins must set name, description, version and author. */
|
||||
PLUGIN_SET_INFO(_("Demo"), _("Example plugin."), VERSION, _("The Geany developer team"))
|
||||
|
||||
|
||||
static GtkWidget *main_menu_item = NULL;
|
||||
/* text to be shown in the plugin dialog */
|
||||
static gchar *welcome_text = NULL;
|
||||
|
||||
@ -94,10 +94,12 @@ void plugin_init(GeanyData *data)
|
||||
gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), demo_item);
|
||||
g_signal_connect(demo_item, "activate", G_CALLBACK(item_activate), NULL);
|
||||
|
||||
welcome_text = g_strdup(_("Hello World!"));
|
||||
|
||||
/* make the menu item sensitive only when documents are open */
|
||||
p_ui->add_document_sensitive(demo_item);
|
||||
/* keep a pointer to the menu item, so we can remove it when the plugin is unloaded */
|
||||
plugin_fields->menu_item = demo_item;
|
||||
main_menu_item = demo_item;
|
||||
|
||||
welcome_text = g_strdup(_("Hello World!"));
|
||||
}
|
||||
|
||||
|
||||
@ -158,7 +160,7 @@ GtkWidget *plugin_configure(GtkDialog *dialog)
|
||||
void plugin_cleanup(void)
|
||||
{
|
||||
/* remove the menu item added in plugin_init() */
|
||||
gtk_widget_destroy(plugin_fields->menu_item);
|
||||
gtk_widget_destroy(main_menu_item);
|
||||
/* release other allocated strings and objects */
|
||||
g_free(welcome_text);
|
||||
}
|
||||
|
@ -38,14 +38,17 @@
|
||||
#include "pluginmacros.h"
|
||||
|
||||
|
||||
PluginFields *plugin_fields;
|
||||
GeanyData *geany_data;
|
||||
GeanyFunctions *geany_functions;
|
||||
|
||||
PLUGIN_VERSION_CHECK(69)
|
||||
PLUGIN_VERSION_CHECK(GEANY_API_VERSION)
|
||||
PLUGIN_SET_INFO(_("Export"), _("Exports the current file into different formats."), VERSION,
|
||||
_("The Geany developer team"))
|
||||
|
||||
|
||||
static GtkWidget *main_menu_item = NULL;
|
||||
|
||||
|
||||
#define ROTATE_RGB(color) \
|
||||
(((color) & 0xFF0000) >> 16) + ((color) & 0x00FF00) + (((color) & 0x0000FF) << 16)
|
||||
#define TEMPLATE_HTML "\
|
||||
@ -731,8 +734,8 @@ void plugin_init(GeanyData *data)
|
||||
G_CALLBACK(on_menu_create_latex_activate), NULL);
|
||||
|
||||
/* disable menu_item when there are no documents open */
|
||||
plugin_fields->menu_item = menu_export;
|
||||
plugin_fields->flags = PLUGIN_IS_DOCUMENT_SENSITIVE;
|
||||
p_ui->add_document_sensitive(menu_export);
|
||||
main_menu_item = menu_export;
|
||||
|
||||
gtk_widget_show_all(menu_export);
|
||||
}
|
||||
@ -740,5 +743,5 @@ void plugin_init(GeanyData *data)
|
||||
|
||||
void plugin_cleanup(void)
|
||||
{
|
||||
gtk_widget_destroy(plugin_fields->menu_item);
|
||||
gtk_widget_destroy(main_menu_item);
|
||||
}
|
||||
|
@ -41,7 +41,6 @@
|
||||
#include "pluginmacros.h"
|
||||
|
||||
|
||||
PluginFields *plugin_fields;
|
||||
GeanyData *geany_data;
|
||||
GeanyFunctions *geany_functions;
|
||||
|
||||
|
@ -35,12 +35,11 @@
|
||||
#include "pluginmacros.h"
|
||||
|
||||
|
||||
PluginFields *plugin_fields;
|
||||
GeanyData *geany_data;
|
||||
GeanyFunctions *geany_functions;
|
||||
|
||||
|
||||
PLUGIN_VERSION_CHECK(69)
|
||||
PLUGIN_VERSION_CHECK(GEANY_API_VERSION)
|
||||
|
||||
PLUGIN_SET_INFO(_("HTML Characters"), _("Inserts HTML character entities like '&'."), VERSION,
|
||||
_("The Geany developer team"))
|
||||
@ -64,6 +63,7 @@ enum
|
||||
};
|
||||
|
||||
|
||||
static GtkWidget *main_menu_item = NULL;
|
||||
static GtkWidget *sc_dialog = NULL;
|
||||
static GtkTreeStore *sc_store = NULL;
|
||||
static GtkTreeView *sc_tree = NULL;
|
||||
@ -521,30 +521,30 @@ static void kb_activate(G_GNUC_UNUSED guint key_id)
|
||||
/* Called by Geany to initialize the plugin */
|
||||
void plugin_init(GeanyData *data)
|
||||
{
|
||||
GtkWidget *demo_item;
|
||||
GtkWidget *menu_item;
|
||||
const gchar *menu_text = _("_Insert Special HTML Characters");
|
||||
gchar *kb_label = _("Insert Special HTML Characters");
|
||||
|
||||
/* 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(geany->main_widgets->tools_menu), demo_item);
|
||||
g_signal_connect(demo_item, "activate", G_CALLBACK(item_activate), NULL);
|
||||
menu_item = gtk_menu_item_new_with_mnemonic(menu_text);
|
||||
gtk_widget_show(menu_item);
|
||||
gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), menu_item);
|
||||
g_signal_connect(menu_item, "activate", G_CALLBACK(item_activate), NULL);
|
||||
|
||||
/* disable menu_item when there are no documents open */
|
||||
plugin_fields->menu_item = demo_item;
|
||||
plugin_fields->flags = PLUGIN_IS_DOCUMENT_SENSITIVE;
|
||||
p_ui->add_document_sensitive(menu_item);
|
||||
main_menu_item = menu_item;
|
||||
|
||||
/* setup keybindings */
|
||||
p_keybindings->set_item(plugin_key_group, KB_INSERT_HTML_CHARS, kb_activate,
|
||||
0, 0, "insert_html_chars", kb_label, demo_item);
|
||||
0, 0, "insert_html_chars", kb_label, menu_item);
|
||||
}
|
||||
|
||||
|
||||
/* Destroy widgets */
|
||||
void plugin_cleanup(void)
|
||||
{
|
||||
gtk_widget_destroy(plugin_fields->menu_item);
|
||||
gtk_widget_destroy(main_menu_item);
|
||||
|
||||
if (sc_dialog != NULL)
|
||||
gtk_widget_destroy(sc_dialog);
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
|
||||
PluginFields *plugin_fields;
|
||||
GeanyData *geany_data;
|
||||
GeanyFunctions *geany_functions;
|
||||
|
||||
|
@ -37,14 +37,14 @@
|
||||
#include "pluginmacros.h"
|
||||
|
||||
|
||||
PLUGIN_VERSION_CHECK(76)
|
||||
PLUGIN_VERSION_CHECK(GEANY_API_VERSION)
|
||||
PLUGIN_SET_INFO(_("Split Window"), _("Splits the editor view into two windows."),
|
||||
"0.1", _("The Geany developer team"))
|
||||
|
||||
|
||||
GeanyData *geany_data;
|
||||
GeanyFunctions *geany_functions;
|
||||
PluginFields *plugin_fields;
|
||||
GeanyData *geany_data;
|
||||
GeanyFunctions *geany_functions;
|
||||
|
||||
|
||||
enum State
|
||||
{
|
||||
@ -338,9 +338,8 @@ void plugin_init(GeanyData *data)
|
||||
GtkWidget *item, *menu;
|
||||
|
||||
menu_items.main = item = gtk_menu_item_new_with_mnemonic(_("_Split Window"));
|
||||
gtk_menu_append(geany_data->main_widgets->tools_menu, menu_items.main);
|
||||
plugin_fields->menu_item = item;
|
||||
plugin_fields->flags = PLUGIN_IS_DOCUMENT_SENSITIVE;
|
||||
gtk_menu_append(geany_data->main_widgets->tools_menu, item);
|
||||
p_ui->add_document_sensitive(item);
|
||||
|
||||
menu = gtk_menu_new();
|
||||
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_items.main), menu);
|
||||
|
@ -43,17 +43,19 @@
|
||||
#define project geany->app->project
|
||||
|
||||
|
||||
PluginFields *plugin_fields;
|
||||
GeanyData *geany_data;
|
||||
GeanyFunctions *geany_functions;
|
||||
|
||||
|
||||
PLUGIN_VERSION_CHECK(69)
|
||||
PLUGIN_VERSION_CHECK(GEANY_API_VERSION)
|
||||
|
||||
PLUGIN_SET_INFO(_("Version Diff"), _("Creates a patch of a file against version control."), VERSION,
|
||||
_("The Geany developer team"))
|
||||
|
||||
|
||||
static GtkWidget *main_menu_item = NULL;
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
VC_COMMAND_DIFF_FILE,
|
||||
@ -534,8 +536,8 @@ void plugin_init(GeanyData *data)
|
||||
|
||||
gtk_widget_show_all(menu_vcdiff);
|
||||
|
||||
plugin_fields->menu_item = menu_vcdiff;
|
||||
plugin_fields->flags = PLUGIN_IS_DOCUMENT_SENSITIVE;
|
||||
p_ui->add_document_sensitive(menu_vcdiff);
|
||||
main_menu_item = menu_vcdiff;
|
||||
}
|
||||
|
||||
|
||||
@ -543,5 +545,5 @@ void plugin_init(GeanyData *data)
|
||||
void plugin_cleanup(void)
|
||||
{
|
||||
/* remove the menu item added in plugin_init() */
|
||||
gtk_widget_destroy(plugin_fields->menu_item);
|
||||
gtk_widget_destroy(main_menu_item);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user