changeset 11817:1bb0efbd4394

[gaim-migrate @ 14108] Patch from sadrul to show the preferences of non-gtk plugins. If this is broken, it is my fault. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Tue, 25 Oct 2005 16:05:26 +0000
parents 60fcaea41fc0
children 9d6e498fe402
files src/gtkplugin.c src/plugin.h
diffstat 2 files changed, 43 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkplugin.c	Tue Oct 25 13:57:23 2005 +0000
+++ b/src/gtkplugin.c	Tue Oct 25 16:05:26 2005 +0000
@@ -25,6 +25,7 @@
 #include "internal.h"
 #include "gtkgaim.h"
 #include "gtkplugin.h"
+#include "gtkpluginpref.h"
 #include "debug.h"
 #include "prefs.h"
 
@@ -38,20 +39,40 @@
 GtkWidget *
 gaim_gtk_plugin_get_config_frame(GaimPlugin *plugin)
 {
-	GaimGtkPluginUiInfo *ui_info;
+	GtkWidget *config = NULL;
 
 	g_return_val_if_fail(plugin != NULL, NULL);
-	g_return_val_if_fail(GAIM_IS_GTK_PLUGIN(plugin), NULL);
 
-	if (plugin->info->ui_info == NULL)
-		return NULL;
+	if (GAIM_IS_GTK_PLUGIN(plugin) && plugin->info->ui_info
+		&& GAIM_GTK_PLUGIN_UI_INFO(plugin)->get_config_frame)
+	{
+		GaimGtkPluginUiInfo *ui_info;
+
+		ui_info = GAIM_GTK_PLUGIN_UI_INFO(plugin);
+
+		config = ui_info->get_config_frame(plugin);
 
-	ui_info = GAIM_GTK_PLUGIN_UI_INFO(plugin);
+		if (plugin->info->prefs_info
+			&& plugin->info->prefs_info->get_plugin_pref_frame)
+		{
+			gaim_debug_warning("gtkplugin",
+				"Plugin %s contains both, ui_info and "
+				"prefs_info preferences; prefs_info will be "
+				"ignored.", plugin->info->name);
+		}
+	}
 
-	if (ui_info->get_config_frame == NULL)
-		return NULL;
+	if (config == NULL && plugin->info->prefs_info
+		&& plugin->info->prefs_info->get_plugin_pref_frame)
+	{
+		GaimPluginPrefFrame *frame;
 
-	return ui_info->get_config_frame(plugin);
+		frame = plugin->info->prefs_info->get_plugin_pref_frame(plugin);
+
+		config = gaim_gtk_plugin_pref_create_frame(frame);
+	}
+
+	return config;
 }
 
 void
@@ -153,9 +174,11 @@
 	}
 
 	gtk_widget_set_sensitive(pref_button,
-				 plug->info->ui_info != NULL &&
-				 GAIM_GTK_PLUGIN_UI_INFO(plug)->get_config_frame != NULL &&
-				 gaim_plugin_is_loaded(plug));
+		gaim_plugin_is_loaded(plug)
+		&& ((GAIM_IS_GTK_PLUGIN(plug) && plug->info->ui_info
+			&& GAIM_GTK_PLUGIN_UI_INFO(plug)->get_config_frame)
+		 || (plug->info->prefs_info
+			&& plug->info->prefs_info->get_plugin_pref_frame)));
 
 	gdk_window_set_cursor(plugin_dialog->window, NULL);
 
@@ -222,10 +245,13 @@
 		   pdesc ? pdesc : "", pdesc ? "\n\n" : "",
 		   pauth ? pauth : "", pweb ? pweb : "", plug->path);
 
-	gtk_widget_set_sensitive(pref_button, 
-				 plug->info->ui_info != NULL &&  
-				 GAIM_GTK_PLUGIN_UI_INFO(plug)->get_config_frame != NULL &&
-				 gaim_plugin_is_loaded(plug));
+	gtk_widget_set_sensitive(pref_button,
+		gaim_plugin_is_loaded(plug)
+		&& ((GAIM_IS_GTK_PLUGIN(plug) && plug->info->ui_info
+			&& GAIM_GTK_PLUGIN_UI_INFO(plug)->get_config_frame)
+		 || (plug->info->prefs_info
+			&& plug->info->prefs_info->get_plugin_pref_frame)));
+
 	gtk_label_set_markup(GTK_LABEL(plugin_details), buf);
 	g_value_unset(&val);
 	g_free(buf);
--- a/src/plugin.h	Tue Oct 25 13:57:23 2005 +0000
+++ b/src/plugin.h	Tue Oct 25 16:05:26 2005 +0000
@@ -106,9 +106,9 @@
 	gboolean (*unload)(GaimPlugin *plugin);
 	void (*destroy)(GaimPlugin *plugin);
 
-	void *ui_info;
+	void *ui_info; /**< Used only by UI-specific plugins to build a preference screen with a custom UI */
 	void *extra_info;
-	GaimPluginUiInfo *prefs_info;
+	GaimPluginUiInfo *prefs_info; /**< Used by any plugin to display preferences.  If #ui_info has been specified, this will be ignored. */
 	GList *(*actions)(GaimPlugin *plugin, gpointer context);
 };