Add plugin_configure_single() plugin symbol which is easier to
implement than plugin_configure() but won't support a multiple-plugin configure dialog. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4233 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
a60a63cc39
commit
20a5fb25f6
@ -6,6 +6,10 @@
|
||||
* src/document.c:
|
||||
Fix showing the document before reload dialog when opening an
|
||||
already-open file.
|
||||
* src/pluginprivate.h, src/plugins.c, doc/pluginsymbols.c:
|
||||
Add plugin_configure_single() plugin symbol which is easier to
|
||||
implement than plugin_configure() but won't support a
|
||||
multiple-plugin configure dialog.
|
||||
|
||||
|
||||
2009-09-22 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
||||
|
@ -76,13 +76,22 @@ PluginCallback plugin_callbacks[];
|
||||
KeyBindingGroup *plugin_key_group;
|
||||
|
||||
|
||||
/** Called before showing the plugin preferences dialog to let the user set some basic
|
||||
* plugin configuration options. Can be omitted when not needed.
|
||||
/** Called before showing the plugin preferences dialog for multiple plugins.
|
||||
* Can be omitted when not needed.
|
||||
* The dialog will show all plugins that support this symbol together.
|
||||
* @param dialog The plugin preferences dialog widget - this should only be used to
|
||||
* connect the @c "response" signal. If settings should be read from the dialog, the
|
||||
* reponse will be either @c GTK_RESPONSE_OK or @c GTK_RESPONSE_APPLY.
|
||||
* @return A container widget holding preference widgets. */
|
||||
GtkWidget* plugin_configure(GtkDialog *dialog);
|
||||
* @return A container widget holding preference widgets.
|
||||
* @see plugin_configure_single(). */
|
||||
GtkWidget *plugin_configure(GtkDialog *dialog);
|
||||
|
||||
/** Called when a plugin should show a preferences dialog, if plugin_configure() has not been
|
||||
* implemented.
|
||||
* @note It's better to implement plugin_configure() instead, but this is simpler.
|
||||
* @param parent Pass this as the parent widget if showing a dialog.
|
||||
* @see plugin_configure(). */
|
||||
void plugin_configure_single(GtkWidget *parent);
|
||||
|
||||
/** Called after loading the plugin.
|
||||
* @param data The same as #geany_data. */
|
||||
|
@ -46,8 +46,9 @@ typedef struct GeanyPluginPrivate
|
||||
GeanyPlugin public; /* fields the plugin can read */
|
||||
|
||||
void (*init) (GeanyData *data); /* Called when the plugin is enabled */
|
||||
GtkWidget* (*configure) (GtkDialog *dialog); /* plugin configure dialog, optional */
|
||||
void (*help) (void); /* Called when the plugin should show some help, optional */
|
||||
GtkWidget* (*configure) (GtkDialog *dialog); /* plugins configure dialog, optional */
|
||||
void (*configure_single) (GtkWidget *parent); /* plugin configure dialog, optional */
|
||||
void (*help) (void); /* Called when the plugin should show some help, optional */
|
||||
void (*cleanup) (void); /* Called when the plugin is disabled or when Geany exits */
|
||||
|
||||
/* extra stuff */
|
||||
|
@ -527,6 +527,12 @@ plugin_init(Plugin *plugin)
|
||||
|
||||
/* store some function pointers for later use */
|
||||
g_module_symbol(plugin->module, "plugin_configure", (void *) &plugin->configure);
|
||||
g_module_symbol(plugin->module, "plugin_configure_single", (void *) &plugin->configure_single);
|
||||
if (app->debug_mode && plugin->configure && plugin->configure_single)
|
||||
g_warning("Plugin '%s' implements plugin_configure_single() unnecessarily - "
|
||||
"only plugin_configure() will be used!",
|
||||
plugin->info.name);
|
||||
|
||||
g_module_symbol(plugin->module, "plugin_help", (void *) &plugin->help);
|
||||
g_module_symbol(plugin->module, "plugin_cleanup", (void *) &plugin->cleanup);
|
||||
if (plugin->cleanup == NULL)
|
||||
@ -980,7 +986,18 @@ PluginManagerWidgets;
|
||||
static PluginManagerWidgets pm_widgets;
|
||||
|
||||
|
||||
void pm_selection_changed(GtkTreeSelection *selection, gpointer user_data)
|
||||
static void pm_update_buttons(Plugin *p)
|
||||
{
|
||||
gboolean is_active;
|
||||
|
||||
is_active = is_active_plugin(p);
|
||||
gtk_widget_set_sensitive(pm_widgets.configure_button,
|
||||
(p->configure || p->configure_single) && is_active);
|
||||
gtk_widget_set_sensitive(pm_widgets.help_button, p->help != NULL && is_active);
|
||||
}
|
||||
|
||||
|
||||
static void pm_selection_changed(GtkTreeSelection *selection, gpointer user_data)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GtkTreeModel *model;
|
||||
@ -994,7 +1011,6 @@ void pm_selection_changed(GtkTreeSelection *selection, gpointer user_data)
|
||||
{
|
||||
gchar *text;
|
||||
PluginInfo *pi;
|
||||
gboolean is_active;
|
||||
|
||||
pi = &p->info;
|
||||
text = g_strdup_printf(
|
||||
@ -1004,9 +1020,7 @@ void pm_selection_changed(GtkTreeSelection *selection, gpointer user_data)
|
||||
geany_wrap_label_set_text(GTK_LABEL(pm_widgets.description_label), text);
|
||||
g_free(text);
|
||||
|
||||
is_active = is_active_plugin(p);
|
||||
gtk_widget_set_sensitive(pm_widgets.configure_button, p->configure != NULL && is_active);
|
||||
gtk_widget_set_sensitive(pm_widgets.help_button, p->help != NULL && is_active);
|
||||
pm_update_buttons(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1015,7 +1029,6 @@ void pm_selection_changed(GtkTreeSelection *selection, gpointer user_data)
|
||||
static void pm_plugin_toggled(GtkCellRendererToggle *cell, gchar *pth, gpointer data)
|
||||
{
|
||||
gboolean old_state, state;
|
||||
gboolean is_active;
|
||||
gchar *file_name;
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path = gtk_tree_path_new_from_string(pth);
|
||||
@ -1057,9 +1070,7 @@ static void pm_plugin_toggled(GtkCellRendererToggle *cell, gchar *pth, gpointer
|
||||
PLUGIN_COLUMN_PLUGIN, p, -1);
|
||||
|
||||
/* set again the sensitiveness of the configure and help buttons */
|
||||
is_active = is_active_plugin(p);
|
||||
gtk_widget_set_sensitive(pm_widgets.configure_button, p->configure != NULL && is_active);
|
||||
gtk_widget_set_sensitive(pm_widgets.help_button, p->help != NULL && is_active);
|
||||
pm_update_buttons(p);
|
||||
}
|
||||
g_free(file_name);
|
||||
}
|
||||
@ -1129,7 +1140,7 @@ static void pm_prepare_treeview(GtkWidget *tree, GtkListStore *store)
|
||||
}
|
||||
|
||||
|
||||
static void configure_plugin(Plugin *p)
|
||||
static void configure_plugins(Plugin *p)
|
||||
{
|
||||
GtkWidget *parent = pm_widgets.dialog;
|
||||
GtkWidget *prefs_page, *dialog, *vbox;
|
||||
@ -1162,7 +1173,7 @@ static void configure_plugin(Plugin *p)
|
||||
}
|
||||
|
||||
|
||||
void pm_on_plugin_button_clicked(GtkButton *button, gpointer user_data)
|
||||
static void pm_on_plugin_button_clicked(GtkButton *button, gpointer user_data)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
GtkTreeSelection *selection;
|
||||
@ -1177,7 +1188,15 @@ void pm_on_plugin_button_clicked(GtkButton *button, gpointer user_data)
|
||||
if (p != NULL)
|
||||
{
|
||||
if (GPOINTER_TO_INT(user_data) == PM_BUTTON_CONFIGURE)
|
||||
configure_plugin(p);
|
||||
{
|
||||
if (p->configure)
|
||||
configure_plugins(p);
|
||||
else
|
||||
{
|
||||
g_return_if_fail(p->configure_single);
|
||||
p->configure_single(main_widgets.window);
|
||||
}
|
||||
}
|
||||
else if (GPOINTER_TO_INT(user_data) == PM_BUTTON_HELP && p->help != NULL)
|
||||
p->help();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user