From 5e3cd1571b30766aac0bb23861d2e8fae7677c80 Mon Sep 17 00:00:00 2001 From: Christoph Hohmann Date: Thu, 2 Jan 2003 22:16:35 +0000 Subject: [PATCH] 0.8.8claws42 * src/common/plugin.c fix unloading of all plugins and unload plugins in reverse order * src/gtk/pluginwindow.c implement function of load and unload button * src/gtk/prefswindow.c * src/gtk/prefswindow.h rename register function and add new unregister function * src/plugins/spamassassin/spamassassin_gtk.c unregister prefs page and update for changes in src/gtk/prefswindow.c --- ChangeLog.claws | 18 +++++++ configure.in | 2 +- src/common/plugin.c | 16 ++++-- src/gtk/pluginwindow.c | 58 +++++++++++++++++++-- src/gtk/prefswindow.c | 9 +++- src/gtk/prefswindow.h | 3 +- src/plugins/spamassassin/spamassassin_gtk.c | 10 +++- 7 files changed, 101 insertions(+), 15 deletions(-) diff --git a/ChangeLog.claws b/ChangeLog.claws index d0f59b6d1..87d39e5ce 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,21 @@ +2003-01-02 [christoph] 0.8.8claws42 + + * src/common/plugin.c + fix unloading of all plugins and unload + plugins in reverse order + + * src/gtk/pluginwindow.c + implement function of load and unload button + + * src/gtk/prefswindow.c + * src/gtk/prefswindow.h + rename register function and add new unregister + function + + * src/plugins/spamassassin/spamassassin_gtk.c + unregister prefs page and update for changes in + src/gtk/prefswindow.c + 2003-01-02 [paul] 0.8.8claws41 * po/es.po diff --git a/configure.in b/configure.in index b01777288..48f52939a 100644 --- a/configure.in +++ b/configure.in @@ -11,7 +11,7 @@ MINOR_VERSION=8 MICRO_VERSION=8 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=claws41 +EXTRA_VERSION=claws42 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION dnl set $target diff --git a/src/common/plugin.c b/src/common/plugin.c index ec38f0676..adb484f37 100644 --- a/src/common/plugin.c +++ b/src/common/plugin.c @@ -61,6 +61,7 @@ void plugin_save_list() fprintf(pfile->fp, "%s\n", plugin->filename); } + fprintf(pfile->fp, "\n"); if (prefs_file_close(pfile) < 0) g_warning("failed to write plugin list\n"); @@ -133,6 +134,7 @@ void plugin_unload(Plugin *plugin) } g_module_close(plugin->module); + plugins = g_slist_remove(plugins, plugin); g_free(plugin); } @@ -167,13 +169,17 @@ void plugin_load_all() void plugin_unload_all() { - GSList *cur; + GSList *list, *cur; - for (cur = plugins; cur != NULL; cur = g_slist_next(cur)) { - plugin_unload((Plugin *)cur->data); + list = g_slist_copy(plugins); + list = g_slist_reverse(list); + + for(cur = list; cur != NULL; cur = g_slist_next(cur)) { + Plugin *plugin = (Plugin *) cur->data; + + plugin_unload(plugin); } - g_slist_free(plugins); - plugins = NULL; + g_slist_free(list); } GSList *plugin_get_list() diff --git a/src/gtk/pluginwindow.c b/src/gtk/pluginwindow.c index cb9023206..c314f98cb 100644 --- a/src/gtk/pluginwindow.c +++ b/src/gtk/pluginwindow.c @@ -28,11 +28,15 @@ #include "intl.h" #include "plugin.h" +#include "../filesel.h" +#include "../alertpanel.h" + typedef struct _PluginWindow { GtkWidget *window; GtkWidget *plugin_list; GtkWidget *plugin_desc; + GtkWidget *unload_btn; Plugin *selected_plugin; } PluginWindow; @@ -41,6 +45,7 @@ static void close_cb(GtkButton *button, PluginWindow *pluginwindow) { gtk_widget_destroy(pluginwindow->window); g_free(pluginwindow); + plugin_save_list(); } static void set_plugin_list(PluginWindow *pluginwindow) @@ -53,6 +58,8 @@ static void set_plugin_list(PluginWindow *pluginwindow) plugins = plugin_get_list(); gtk_clist_freeze(clist); gtk_clist_clear(clist); + gtk_editable_delete_text(GTK_EDITABLE(pluginwindow->plugin_desc), 0, -1); + gtk_widget_set_sensitive(pluginwindow->unload_btn, FALSE); for(cur = plugins; cur != NULL; cur = g_slist_next(cur)) { Plugin *plugin = (Plugin *) cur->data; @@ -75,9 +82,46 @@ static void select_row_cb(GtkCList *clist, gint row, gint column, plugin = (Plugin *) gtk_clist_get_row_data(clist, row); pluginwindow->selected_plugin = plugin; - gtk_editable_delete_text(plugin_desc, 0, -1); - text = plugin_get_desc(plugin); - gtk_editable_insert_text(plugin_desc, text, strlen(text), &pos); + if (pluginwindow->selected_plugin != NULL) { + gtk_editable_delete_text(plugin_desc, 0, -1); + text = plugin_get_desc(plugin); + gtk_editable_insert_text(plugin_desc, text, strlen(text), &pos); + gtk_widget_set_sensitive(pluginwindow->unload_btn, TRUE); + } else { + gtk_widget_set_sensitive(pluginwindow->unload_btn, FALSE); + } +} + +static void unselect_row_cb(GtkCList * clist, gint row, gint column, + GdkEventButton * event, PluginWindow *pluginwindow) +{ + gtk_widget_set_sensitive(pluginwindow->unload_btn, FALSE); +} + +static void unload_cb(GtkButton *button, PluginWindow *pluginwindow) +{ + Plugin *plugin = pluginwindow->selected_plugin; + + g_return_if_fail(plugin != NULL); + plugin_unload(plugin); + set_plugin_list(pluginwindow); +} + +static void load_cb(GtkButton *button, PluginWindow *pluginwindow) +{ + gchar *file, *error = NULL; + + file = filesel_select_file(_("Select Plugin to load"), ""); + if (file == NULL) + return; + + plugin_load(file, &error); + if (error != NULL) { + alertpanel_error("The following error occured while loading the plugin:\n%s\n", error); + g_free(error); + } + + set_plugin_list(pluginwindow); } void pluginwindow_create() @@ -184,19 +228,25 @@ void pluginwindow_create() /* ----------------------------------------------------------- */ gtk_text_set_word_wrap(GTK_TEXT(plugin_desc), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET(load_btn), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(unload_btn), FALSE); pluginwindow = g_new0(PluginWindow, 1); + gtk_signal_connect(GTK_OBJECT(load_btn), "released", + GTK_SIGNAL_FUNC(load_cb), pluginwindow); + gtk_signal_connect(GTK_OBJECT(unload_btn), "released", + GTK_SIGNAL_FUNC(unload_cb), pluginwindow); gtk_signal_connect(GTK_OBJECT(close_btn), "released", GTK_SIGNAL_FUNC(close_cb), pluginwindow); gtk_signal_connect(GTK_OBJECT(plugin_list), "select-row", GTK_SIGNAL_FUNC(select_row_cb), pluginwindow); + gtk_signal_connect(GTK_OBJECT(plugin_list), "unselect-row", + GTK_SIGNAL_FUNC(unselect_row_cb), pluginwindow); pluginwindow->window = window; pluginwindow->plugin_list = plugin_list; pluginwindow->plugin_desc = plugin_desc; + pluginwindow->unload_btn = unload_btn; pluginwindow->selected_plugin = NULL; set_plugin_list(pluginwindow); diff --git a/src/gtk/prefswindow.c b/src/gtk/prefswindow.c index 7a2431f0a..b0a5717fc 100644 --- a/src/gtk/prefswindow.c +++ b/src/gtk/prefswindow.c @@ -49,11 +49,16 @@ struct _PrefsWindow GtkWidget *apply_btn; }; -void prefswindow_register_new_page(PrefsPage *page) +void prefswindow_register_page(PrefsPage *page) { prefs_pages = g_slist_append(prefs_pages, page); } +void prefswindow_unregister_page(PrefsPage *page) +{ + prefs_pages = g_slist_remove(prefs_pages, page); +} + static gboolean ctree_select_row(GtkCTree *ctree, GList *node, gint column, gpointer user_data) { PrefsPage *page; @@ -170,7 +175,7 @@ static gboolean find_child_by_name(GtkCTree *ctree, GtkCTreeNode *node, struct n void prefswindow_create() { - static gchar *titles [] = {"Pages"}; + static gchar *titles [] = {"Page Index"}; GSList *cur; gint optsize; PrefsWindow *prefswindow; diff --git a/src/gtk/prefswindow.h b/src/gtk/prefswindow.h index a3ba7cc7c..93613b484 100644 --- a/src/gtk/prefswindow.h +++ b/src/gtk/prefswindow.h @@ -42,7 +42,8 @@ struct _PrefsPage PrefsDestroyPageFunc destroy_page; }; -void prefswindow_register_new_page (PrefsPage *); +void prefswindow_register_page (PrefsPage *); +void prefswindow_unregister_page (PrefsPage *); void prefswindow_create (); void prefswindow_destroy_all_pages (); diff --git a/src/plugins/spamassassin/spamassassin_gtk.c b/src/plugins/spamassassin/spamassassin_gtk.c index 87088fb7a..1005f3c02 100644 --- a/src/plugins/spamassassin/spamassassin_gtk.c +++ b/src/plugins/spamassassin/spamassassin_gtk.c @@ -253,6 +253,8 @@ static void spamassassin_destroy_func(PrefsPage *_page) g_free(_page); } +static struct SpamAssassinPage *spamassassin_page; + gint plugin_init(gchar **error) { struct SpamAssassinPage *page; @@ -263,15 +265,19 @@ gint plugin_init(gchar **error) page->page.destroy_widget = spamassassin_destroy_widget_func; page->page.save_page = spamassassin_save_func; page->page.destroy_page = spamassassin_destroy_func; - prefswindow_register_new_page((PrefsPage *) page); + prefswindow_register_page((PrefsPage *) page); - debug_print("SpamAssassin GTK plugin loaded\n"); + spamassassin_page = page; + debug_print("SpamAssassin GTK plugin loaded\n"); return 0; } void plugin_done() { + prefswindow_unregister_page((PrefsPage *) spamassassin_page); + g_free(spamassassin_page); + debug_print("SpamAssassin GTK plugin unloaded\n"); } -- 2.25.1