2006-03-28 [colin] 2.0.0cvs180
[claws.git] / src / gtk / pluginwindow.c
index 764532ff8c19ff8e973ba6d00f7b029ef77ac043..67381f77d5324099e1c200263c1e0da8f884f352 100644 (file)
@@ -28,6 +28,7 @@
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
 
+#include "defs.h"
 #include "plugin.h"
 
 #include "filesel.h"
@@ -38,6 +39,7 @@
 enum {
        PLUGINWINDOW_NAME,              /*<! plugin name */
        PLUGINWINDOW_DATA,              /*<! Plugin pointer */
+       PLUGINWINDOW_STYLE,             /*<! italic if error */
        N_PLUGINWINDOW_COLUMNS
 };
 
@@ -70,7 +72,7 @@ static void close_cb(GtkButton *button, PluginWindow *pluginwindow)
 
 static void set_plugin_list(PluginWindow *pluginwindow)
 {
-       GSList *plugins, *cur;
+       GSList *plugins, *cur, *unloaded;
        const gchar *text;
        GtkListStore *store;
        GtkTreeIter iter;
@@ -79,6 +81,7 @@ static void set_plugin_list(PluginWindow *pluginwindow)
        GtkTreeSelection *selection;
 
        plugins = plugin_get_list();
+       unloaded = plugin_get_unloaded_list();
 
        store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW
                                (pluginwindow->plugin_list_view)));
@@ -102,6 +105,19 @@ static void set_plugin_list(PluginWindow *pluginwindow)
                gtk_list_store_set(store, &iter,
                                   PLUGINWINDOW_NAME, text,
                                   PLUGINWINDOW_DATA, plugin,
+                                  PLUGINWINDOW_STYLE, PANGO_STYLE_NORMAL,
+                                  -1);
+       }
+
+       for(cur = unloaded; cur != NULL; cur = g_slist_next(cur)) {
+               Plugin *plugin = (Plugin *) cur->data;
+
+               gtk_list_store_append(store, &iter);
+               text = plugin_get_name(plugin);
+               gtk_list_store_set(store, &iter,
+                                  PLUGINWINDOW_NAME, text,
+                                  PLUGINWINDOW_DATA, plugin,
+                                  PLUGINWINDOW_STYLE, PANGO_STYLE_ITALIC,
                                   -1);
        }
 
@@ -118,17 +134,27 @@ static void select_row_cb(Plugin *plugin, PluginWindow *pluginwindow)
        GtkTextView *plugin_desc = GTK_TEXT_VIEW(pluginwindow->plugin_desc);
        GtkTextBuffer *textbuf = gtk_text_view_get_buffer(plugin_desc);
        GtkTextIter start_iter, end_iter;
-       const gchar *text;
+       gchar *text;
 
        pluginwindow->selected_plugin = plugin;
 
        if (pluginwindow->selected_plugin != NULL) {
+               const gchar *desc = plugin_get_desc(plugin);
+               const gchar *err = plugin_get_error(plugin);
                gtk_text_buffer_get_start_iter(textbuf, &start_iter);
                gtk_text_buffer_get_end_iter(textbuf, &end_iter);
                gtk_text_buffer_delete(textbuf, &start_iter, &end_iter);
-               text = g_strconcat(plugin_get_desc(plugin), _("\n\nVersion: "),
+               
+               if (err == NULL)
+                       text = g_strconcat(desc, _("\n\nVersion: "),
+                                  plugin_get_version(plugin), "\n", NULL);
+               else
+                       text = g_strconcat(_("Error: "),
+                                  err, "\n", _("Plugin is not functional."), 
+                                  "\n\n", desc, _("\n\nVersion: "),
                                   plugin_get_version(plugin), "\n", NULL);
                gtk_text_buffer_insert(textbuf, &start_iter, text, strlen(text));
+               g_free(text);
                gtk_widget_set_sensitive(pluginwindow->unload_btn, TRUE);
        } else {
                gtk_widget_set_sensitive(pluginwindow->unload_btn, FALSE);
@@ -239,10 +265,11 @@ void pluginwindow_create()
        GtkWidget *label13;
        GtkWidget *scrolledwindow3;
        GtkWidget *plugin_desc;
-       GtkWidget *hbuttonbox1;
+       GtkWidget *hbuttonbox1, *hbox3;
        GtkWidget *load_btn;
        GtkWidget *unload_btn;
        GtkWidget *close_btn;
+       GtkWidget *get_more_btn;
        static GdkGeometry geometry;
        
        debug_print("Creating plugins window...\n");
@@ -299,9 +326,19 @@ void pluginwindow_create()
        gtk_widget_show(plugin_desc);
        gtk_container_add(GTK_CONTAINER(scrolledwindow3), plugin_desc);
 
+       hbox3 = gtk_hbox_new(FALSE, 0);
+       gtk_widget_show(hbox3);
        hbuttonbox1 = gtk_hbutton_box_new();
        gtk_widget_show(hbuttonbox1);
-       gtk_box_pack_start(GTK_BOX(vbox1), hbuttonbox1, FALSE, FALSE, 0);
+
+       gtk_widget_realize(window);
+       get_more_btn = gtkut_get_link_btn(window, PLUGINS_URI, _("Get more..."));
+       gtk_misc_set_alignment(GTK_MISC(GTK_BIN(get_more_btn)->child), 0, 0.5);
+       gtk_widget_show(get_more_btn);
+
+       gtk_box_pack_start(GTK_BOX(hbox3), get_more_btn, TRUE, TRUE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox3), hbuttonbox1, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(vbox1), hbox3, FALSE, FALSE, 0);
        gtk_button_box_set_layout(GTK_BUTTON_BOX(hbuttonbox1),
                                  GTK_BUTTONBOX_END);
        gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbuttonbox1), 6);
@@ -365,6 +402,7 @@ static GtkListStore* pluginwindow_create_data_store(void)
        return gtk_list_store_new(N_PLUGINWINDOW_COLUMNS,
                                  G_TYPE_STRING,        
                                  G_TYPE_POINTER,
+                                 PANGO_TYPE_STYLE,
                                  -1);
 }
 
@@ -402,6 +440,7 @@ static void pluginwindow_create_list_view_columns(GtkWidget *list_view)
                (_("Plugins"),
                 renderer,
                 "text", PLUGINWINDOW_NAME,
+                "style", PLUGINWINDOW_STYLE,
                 NULL);
        gtk_tree_view_append_column(GTK_TREE_VIEW(list_view), column);          
 }