SF.net SVN: geany:[4233] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Thu Sep 24 16:29:11 UTC 2009


Revision: 4233
          http://geany.svn.sourceforge.net/geany/?rev=4233&view=rev
Author:   ntrel
Date:     2009-09-24 16:28:59 +0000 (Thu, 24 Sep 2009)

Log Message:
-----------
Add plugin_configure_single() plugin symbol which is easier to
implement than plugin_configure() but won't support a
multiple-plugin configure dialog.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/doc/pluginsymbols.c
    trunk/src/pluginprivate.h
    trunk/src/plugins.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-09-24 16:19:27 UTC (rev 4232)
+++ trunk/ChangeLog	2009-09-24 16:28:59 UTC (rev 4233)
@@ -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>

Modified: trunk/doc/pluginsymbols.c
===================================================================
--- trunk/doc/pluginsymbols.c	2009-09-24 16:19:27 UTC (rev 4232)
+++ trunk/doc/pluginsymbols.c	2009-09-24 16:28:59 UTC (rev 4233)
@@ -76,14 +76,23 @@
 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. */
 void plugin_init(GeanyData *data);

Modified: trunk/src/pluginprivate.h
===================================================================
--- trunk/src/pluginprivate.h	2009-09-24 16:19:27 UTC (rev 4232)
+++ trunk/src/pluginprivate.h	2009-09-24 16:28:59 UTC (rev 4233)
@@ -46,8 +46,9 @@
 	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 */

Modified: trunk/src/plugins.c
===================================================================
--- trunk/src/plugins.c	2009-09-24 16:19:27 UTC (rev 4232)
+++ trunk/src/plugins.c	2009-09-24 16:28:59 UTC (rev 4233)
@@ -527,6 +527,12 @@
 
 	/* 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,8 +986,19 @@
 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;
 	Plugin *p;
@@ -994,7 +1011,6 @@
 		{
 			gchar *text;
 			PluginInfo *pi;
-			gboolean is_active;
 
 			pi = &p->info;
 			text = g_strdup_printf(
@@ -1004,9 +1020,7 @@
 			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 @@
 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 @@
 			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 configure_plugin(Plugin *p)
+static void configure_plugins(Plugin *p)
 {
 	GtkWidget *parent = pm_widgets.dialog;
 	GtkWidget *prefs_page, *dialog, *vbox;
@@ -1162,7 +1173,7 @@
 }
 
 
-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 @@
 		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();
 		}


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list