changeset 8745:6c0fae7a4f1a

[gaim-migrate @ 9500] " fixed up an issue in the example plugin and a memory leak and some other code.." --Gary Kramlich committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Wed, 21 Apr 2004 21:05:08 +0000
parents 0f73e8204529
children dbe23964ff2b
files plugins/pluginpref_example.c src/gtkprefs.c src/pluginpref.c
diffstat 3 files changed, 50 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/pluginpref_example.c	Wed Apr 21 21:01:42 2004 +0000
+++ b/plugins/pluginpref_example.c	Wed Apr 21 21:05:08 2004 +0000
@@ -33,7 +33,7 @@
 #include "pluginpref.h"
 #include "prefs.h"
 
-GaimPluginPrefFrame *
+static GaimPluginPrefFrame *
 get_plugin_pref_frame(GaimPlugin *plugin) {
 	GaimPluginPrefFrame *frame;
 	GaimPluginPref *ppref;
@@ -146,4 +146,4 @@
 	gaim_prefs_add_string("/plugins/core/pluginpref_example/string_choice", "red");
 }
 
-GAIM_INIT_PLUGIN(relnot, init_plugin, info)
+GAIM_INIT_PLUGIN(ppexample, init_plugin, info)
--- a/src/gtkprefs.c	Wed Apr 21 21:01:42 2004 +0000
+++ b/src/gtkprefs.c	Wed Apr 21 21:05:08 2004 +0000
@@ -357,6 +357,17 @@
 				ui_info->iter = NULL;
 			}
 		}
+
+		if(GAIM_PLUGIN_HAS_PREF_FRAME(plug)) {
+			GaimPluginUiInfo *prefs_info;
+
+			prefs_info = GAIM_PLUGIN_UI_INFO(plug);
+
+			if(prefs_info->iter != NULL) {
+				g_free(prefs_info->iter);
+				prefs_info->iter = NULL;
+			}
+		}
 	}
 }
 
@@ -1873,15 +1884,19 @@
 				g_free(ui_info->iter);
 				ui_info->iter = NULL;
 			}
-		} else if (GAIM_PLUGIN_HAS_PREF_FRAME(plug)) {
+		}
+
+		if (GAIM_PLUGIN_HAS_PREF_FRAME(plug)) {
 			GaimPluginUiInfo *prefs_info;
 
 			prefs_info = GAIM_PLUGIN_UI_INFO(plug);
 
-			if(prefs_info != NULL && prefs_info->iter != NULL) {
-				gtk_tree_store_remove(GTK_TREE_STORE(prefstree), prefs_info->iter);
-				g_free(prefs_info->iter);
-				prefs_info->iter = NULL;
+			if(prefs_info != NULL) {
+				if(prefs_info->iter != NULL) {
+					gtk_tree_store_remove(GTK_TREE_STORE(prefstree), prefs_info->iter);
+					g_free(prefs_info->iter);
+					prefs_info->iter = NULL;
+				}
 			}
 		}
 
@@ -2526,16 +2541,19 @@
 			}
 
 			if(GAIM_PLUGIN_HAS_PREF_FRAME(plug)) {
-				GtkWidget *pref_frame;
+				GtkWidget *gtk_frame;
+				GaimPluginPrefFrame *pp_frame;
 				GaimPluginUiInfo *prefs_info;
 
 				prefs_info = GAIM_PLUGIN_UI_INFO(plug);
-				pref_frame = gaim_gtk_plugin_pref_create_frame(prefs_info->get_plugin_pref_frame(plug));
-
-				if(pref_frame != NULL) {
+				pp_frame = prefs_info->get_plugin_pref_frame(plug);
+				gtk_frame = gaim_gtk_plugin_pref_create_frame(pp_frame);
+				gaim_plugin_pref_frame_destroy(pp_frame);
+
+				if(GTK_IS_WIDGET(gtk_frame)) {
 					prefs_info->iter = g_new0(GtkTreeIter, 1);
 					prefs_notebook_add_page(_(plug->info->name), NULL,
-										pref_frame, prefs_info->iter,
+										gtk_frame, prefs_info->iter,
 										(plug->info->type == GAIM_PLUGIN_PROTOCOL) ? &proto_iter : &plugin_iter,
 										notebook_page++);
 				}
@@ -2988,4 +3006,3 @@
 	gaim_prefs_rename_boolean_toggle("/gaim/gtk/sound/silent_signon",
 									 "/gaim/gtk/sound/signon");
 }
-
--- a/src/pluginpref.c	Wed Apr 21 21:01:42 2004 +0000
+++ b/src/pluginpref.c	Wed Apr 21 21:05:08 2004 +0000
@@ -58,19 +58,19 @@
 void
 gaim_plugin_pref_frame_destroy(GaimPluginPrefFrame *frame) {
 	GaimPluginPref *pref;
-	GList *l, *ll;
+	GList *l;
 
 	g_return_if_fail(frame);
 
-	for(l = frame->prefs; l != NULL; l = ll) {
-		ll = l->next;
-
+	for(l = frame->prefs; l != NULL; l = l->next) {
 		pref = (GaimPluginPref *)l->data;
 		gaim_plugin_pref_destroy(pref);
-
-		g_list_free_1(l);
 	}
 
+	g_list_free(frame->prefs);
+	frame->prefs = NULL;
+
+	g_free(frame);
 	frame = NULL;
 }
 
@@ -79,11 +79,14 @@
 	g_return_if_fail(frame);
 	g_return_if_fail(pref);
 
-	frame->prefs = g_list_append(frame->prefs, (gpointer)pref);
+	frame->prefs = g_list_append(frame->prefs, pref);
 }
 
 GList *
 gaim_plugin_pref_frame_get_prefs(GaimPluginPrefFrame *frame) {
+	g_return_val_if_fail(frame, NULL);
+	g_return_val_if_fail(frame->prefs, NULL);
+
 	return frame->prefs;
 }
 
@@ -140,20 +143,19 @@
 
 	g_return_if_fail(pref);
 
-	if(pref->name)
+	if(pref->name) {
 		g_free(pref->name);
-
-	if(pref->label)
-		g_free(pref->label);
+		pref->name = NULL;
+	}
 
-	l = pref->choices;
-	while(l) {
-		ll = l->next;
+	if(pref->label) {
+		g_free(pref->label);
+		pref->label = NULL;
+	}
 
-		g_free(l->data);
-		g_list_free_1(l);
-
-		l = l->next;
+	if(pref->choices) {
+		g_list_free(pref->choices);
+		pref->choices = NULL;
 	}
 
 	g_free(pref);
@@ -258,16 +260,6 @@
 	pref->choices = g_list_append(pref->choices, choice);
 }
 
-gpointer
-gaim_plugin_pref_get_choice(GaimPluginPref *pref, unsigned int index) {
-	g_return_val_if_fail(pref, NULL);
-
-	if(index > g_list_length(pref->choices))
-		return NULL;
-
-	return g_list_nth_data(pref->choices, index);
-}
-
 GList *
 gaim_plugin_pref_get_choices(GaimPluginPref *pref) {
 	g_return_val_if_fail(pref, NULL);