2005-12-19 [paul] 1.9.100cvs94
[claws.git] / src / gtk / pluginwindow.c
index a45566617fa0ffb5719a54318db8d57fd1712863..134ea12aba4b9d7a03fc2d7d41b0919be20aab93 100644 (file)
@@ -14,7 +14,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -72,7 +72,6 @@ static void set_plugin_list(PluginWindow *pluginwindow)
 {
        GSList *plugins, *cur;
        const gchar *text;
-       gint row;
        GtkListStore *store;
        GtkTreeIter iter;
        GtkTextBuffer *textbuf;
@@ -83,6 +82,8 @@ static void set_plugin_list(PluginWindow *pluginwindow)
 
        store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW
                                (pluginwindow->plugin_list_view)));
+       gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store),
+                                             0, GTK_SORT_ASCENDING);
        gtk_list_store_clear(store);
        
        textbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pluginwindow->plugin_desc));
@@ -125,7 +126,8 @@ static void select_row_cb(Plugin *plugin, PluginWindow *pluginwindow)
                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 = plugin_get_desc(plugin);
+               text = g_strconcat(plugin_get_desc(plugin), _("\n\nVersion: "),
+                                  plugin_get_version(plugin), "\n", NULL);
                gtk_text_buffer_insert(textbuf, &start_iter, text, strlen(text));
                gtk_widget_set_sensitive(pluginwindow->unload_btn, TRUE);
        } else {
@@ -152,13 +154,15 @@ static void load_cb(GtkButton *button, PluginWindow *pluginwindow)
 {
        gchar *file, *error = NULL;
 
-       file = filesel_select_file_open(_("Select Plugin to load"), PLUGINDIR);
+       file = filesel_select_file_open_with_filter(_("Select Plugin to load"), 
+                                                   PLUGINDIR, 
+                                                   "*." G_MODULE_SUFFIX);
        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);
+               alertpanel_error(_("The following error occured while loading the plugin:\n%s\n"), error);
                g_free(error);
        }
 
@@ -195,6 +199,19 @@ static gboolean pluginwindow_key_pressed(GtkWidget *widget, GdkEventKey *event,
        return FALSE;
 }
 
+/*!
+ *\brief       Save Gtk object size to prefs dataset
+ */
+static void pluginwindow_size_allocate_cb(GtkWidget *widget,
+                                        GtkAllocation *allocation)
+{
+       g_return_if_fail(allocation != NULL);
+
+       prefs_common.pluginswin_width = allocation->width;
+       prefs_common.pluginswin_height = allocation->height;
+}
+
+
 void pluginwindow_create()
 {
        PluginWindow *pluginwindow;
@@ -213,12 +230,14 @@ void pluginwindow_create()
        GtkWidget *load_btn;
        GtkWidget *unload_btn;
        GtkWidget *close_btn;
+       static GdkGeometry geometry;
        
+       debug_print("Creating plugins window...\n");
+
        pluginwindow = g_new0(PluginWindow, 1);
 
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_container_set_border_width(GTK_CONTAINER(window), 8);
-       gtk_window_set_default_size(GTK_WINDOW(window), 480, 300);
        gtk_window_set_title(GTK_WINDOW(window), _("Plugins"));
        gtk_window_set_modal(GTK_WINDOW(window), TRUE);
 
@@ -274,7 +293,7 @@ void pluginwindow_create()
                                  GTK_BUTTONBOX_END);
        gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbuttonbox1), 6);
 
-       load_btn = gtk_button_new_with_label(_("Load Plugin"));
+       load_btn = gtk_button_new_with_label(_("Load Plugin..."));
        gtk_widget_show(load_btn);
        gtk_container_add(GTK_CONTAINER(hbuttonbox1), load_btn);
        GTK_WIDGET_SET_FLAGS(load_btn, GTK_CAN_DEFAULT);
@@ -300,6 +319,8 @@ void pluginwindow_create()
                         G_CALLBACK(unload_cb), pluginwindow);
        g_signal_connect(G_OBJECT(close_btn), "released",
                         G_CALLBACK(close_cb), pluginwindow);
+       g_signal_connect(G_OBJECT(window), "size_allocate",
+                        G_CALLBACK(pluginwindow_size_allocate_cb), NULL);
        g_signal_connect(G_OBJECT(window), "key_press_event",
                           G_CALLBACK(pluginwindow_key_pressed), pluginwindow);
 
@@ -312,6 +333,17 @@ void pluginwindow_create()
        set_plugin_list(pluginwindow);
 
        inc_lock();
+
+       if (!geometry.min_height) {
+               geometry.min_width = 480;
+               geometry.min_height = 300;
+       }
+
+       gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
+                                     GDK_HINT_MIN_SIZE);
+       gtk_widget_set_size_request(window, prefs_common.pluginswin_width,
+                                   prefs_common.pluginswin_height);
+
        gtk_widget_show(window);
 }