Skip to content

Commit

Permalink
Merge pull request #700 from LarsGit223/autoclose-newapi
Browse files Browse the repository at this point in the history
autoclose: use new plugin API
  • Loading branch information
frlan committed Apr 14, 2019
2 parents 7093263 + 8bd8316 commit 5be223b
Showing 1 changed file with 38 additions and 17 deletions.
55 changes: 38 additions & 17 deletions autoclose/src/autoclose.c
Expand Up @@ -42,14 +42,6 @@
GeanyPlugin *geany_plugin;
GeanyData *geany_data;

PLUGIN_VERSION_CHECK(224)
PLUGIN_SET_TRANSLATABLE_INFO(
LOCALEDIR,
GETTEXT_PACKAGE,
_("Auto-close"),
_("Auto-close braces and brackets with lot of features"),
"0.3",
"Pavel Roschin <rpg89(at)post(dot)ru>")

typedef struct {
/* close chars */
Expand Down Expand Up @@ -830,7 +822,7 @@ on_document_open(GObject *obj, GeanyDocument *doc, gpointer user_data)
g_object_set_data_full(G_OBJECT(sci), "autoclose-userdata", data, g_free);
}

PluginCallback plugin_callbacks[] =
static PluginCallback plugin_autoclose_callbacks[] =
{
{ "document-open", (GCallback) &on_document_open, FALSE, NULL },
{ "document-new", (GCallback) &on_document_open, FALSE, NULL },
Expand Down Expand Up @@ -896,11 +888,14 @@ configure_response_cb(GtkDialog *dialog, gint response, gpointer user_data)
}

/* Called by Geany to initialize the plugin */
void
plugin_init(G_GNUC_UNUSED GeanyData *data)
static gboolean
plugin_autoclose_init(GeanyPlugin *plugin, G_GNUC_UNUSED gpointer pdata)
{
guint i = 0;

geany_plugin = plugin;
geany_data = plugin->geany_data;

foreach_document(i)
{
on_document_open(NULL, documents[i], NULL);
Expand Down Expand Up @@ -943,6 +938,7 @@ plugin_init(G_GNUC_UNUSED GeanyData *data)
#undef GET_CONF_BOOL

g_key_file_free(config);
return TRUE;
}

#define GET_CHECKBOX_ACTIVE(name) gboolean sens = gtk_toggle_button_get_active(\
Expand Down Expand Up @@ -1002,8 +998,8 @@ ac_delete_pairing_brace_cb(GtkToggleButton *togglebutton, gpointer data)
SET_SENS(bcksp_remove_pair);
}

GtkWidget *
plugin_configure(GtkDialog *dialog)
static GtkWidget *
plugin_autoclose_configure(G_GNUC_UNUSED GeanyPlugin *plugin, GtkDialog *dialog, G_GNUC_UNUSED gpointer pdata)
{
GtkWidget *widget, *vbox, *frame, *container, *scrollbox;
vbox = gtk_vbox_new(FALSE, 0);
Expand Down Expand Up @@ -1134,16 +1130,41 @@ autoclose_cleanup(void)
}

/* Called by Geany before unloading the plugin. */
void
plugin_cleanup(void)
static void
plugin_autoclose_cleanup(G_GNUC_UNUSED GeanyPlugin *plugin, G_GNUC_UNUSED gpointer pdata)
{
autoclose_cleanup();
g_free(ac_info->config_file);
g_free(ac_info);
}

void
plugin_help(void)
static void
plugin_autoclose_help(G_GNUC_UNUSED GeanyPlugin *plugin, G_GNUC_UNUSED gpointer pdata)
{
utils_open_browser("http://plugins.geany.org/autoclose.html");
}


/* Load module */
G_MODULE_EXPORT
void geany_load_module(GeanyPlugin *plugin)
{
/* Setup translation */
main_locale_init(LOCALEDIR, GETTEXT_PACKAGE);

/* Set metadata */
plugin->info->name = _("Auto-close");
plugin->info->description = _("Auto-close braces and brackets with lot of features");
plugin->info->version = "0.3";
plugin->info->author = "Pavel Roschin <rpg89(at)post(dot)ru>";

/* Set functions */
plugin->funcs->init = plugin_autoclose_init;
plugin->funcs->cleanup = plugin_autoclose_cleanup;
plugin->funcs->help = plugin_autoclose_help;
plugin->funcs->callbacks = plugin_autoclose_callbacks;
plugin->funcs->configure = plugin_autoclose_configure;

/* Register! */
GEANY_PLUGIN_REGISTER(plugin, 226);
}

0 comments on commit 5be223b

Please sign in to comment.