2004-12-31 [paul] 0.9.13cvs23.1
authorPaul Mangan <paul@claws-mail.org>
Fri, 31 Dec 2004 08:27:34 +0000 (08:27 +0000)
committerPaul Mangan <paul@claws-mail.org>
Fri, 31 Dec 2004 08:27:34 +0000 (08:27 +0000)
* configure.ac
bump up EXTRA_VERSION to match (sync'ed) HEAD
* src/gtk/pluginwindow.c
use GTK2 widgets and plug memory leaks,
patches by Alfons

ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/gtk/pluginwindow.c

index 0076367..61bbcbd 100644 (file)
@@ -1,3 +1,11 @@
+2004-12-31 [paul]      0.9.13cvs23.1
+
+       * configure.ac
+               bump up EXTRA_VERSION to match (sync'ed) HEAD
+       * src/gtk/pluginwindow.c
+               use GTK2 widgets and plug memory leaks,
+               patches by Alfons
+
 2004-12-30 [colin]     0.9.13cvs22.4
 
        * src/account.c
index 8ba86c4..6eefb6a 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.26.2.6 -r 1.26.2.7 src/foldersel.c; ) > 0.9.13cvs22.2.patchset
 ( cvs diff -u -r 1.61.2.16 -r 1.61.2.17 src/account.c; cvs diff -u -r 1.60.2.5 -r 1.60.2.6 src/prefs_actions.c; cvs diff -u -r 1.16.2.4 -r 1.16.2.5 src/prefs_customheader.c; cvs diff -u -r 1.59.2.10 -r 1.59.2.11 src/prefs_filtering.c; cvs diff -u -r 1.1.2.6 -r 1.1.2.7 src/prefs_msg_colors.c; cvs diff -u -r 1.10.2.2 -r 1.10.2.3 src/prefs_summary_column.c; cvs diff -u -r 1.12.2.11 -r 1.12.2.12 src/gtk/prefswindow.c; ) > 0.9.13cvs22.3.patchset
 ( cvs diff -u -r 1.61.2.17 -r 1.61.2.18 src/account.c; cvs diff -u -r 1.12.2.17 -r 1.12.2.18 src/action.c; cvs diff -u -r 1.8.2.3 -r 1.8.2.4 src/export.c; cvs diff -u -r 1.26.2.7 -r 1.26.2.8 src/foldersel.c; cvs diff -u -r 1.13.2.4 -r 1.13.2.5 src/import.c; cvs diff -u -r 1.3.12.5 -r 1.3.12.6 src/message_search.c; cvs diff -u -r 1.60.2.6 -r 1.60.2.7 src/prefs_actions.c; cvs diff -u -r 1.204.2.25 -r 1.204.2.26 src/prefs_common.c; cvs diff -u -r 1.16.2.5 -r 1.16.2.6 src/prefs_customheader.c; cvs diff -u -r 1.59.2.11 -r 1.59.2.12 src/prefs_filtering.c; cvs diff -u -r 1.10.2.3 -r 1.10.2.4 src/prefs_summary_column.c; cvs diff -u -r 1.15.2.11 -r 1.15.2.12 src/summary_search.c; cvs diff -u -r 1.4.2.4 -r 1.4.2.5 src/gtk/about.c; cvs diff -u -r 1.5.2.5 -r 1.5.2.6 src/gtk/description_window.c; cvs diff -u -r 1.5.2.6 -r 1.5.2.7 src/gtk/gtkutils.c; cvs diff -u -r 1.4.2.5 -r 1.4.2.6 src/gtk/gtkutils.h; cvs diff -u -r 1.2.2.2 -r 1.2.2.3 src/gtk/inputdialog.c; cvs diff -u -r 1.12.2.12 -r 1.12.2.13 src/gtk/prefswindow.c; ) > 0.9.13cvs22.4.patchset
+( cvs diff -u -r 1.654.2.330 -r 1.654.2.331 configure.ac; cvs diff -u -r 1.5.2.9 -r 1.5.2.10 src/gtk/pluginwindow.c; ) > 0.9.13cvs23.1.patchset
index 4f943f1..2c6a2d1 100644 (file)
@@ -11,9 +11,9 @@ MINOR_VERSION=9
 MICRO_VERSION=13
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=22
+EXTRA_VERSION=23
 EXTRA_RELEASE=
-EXTRA_GTK2_VERSION=.4
+EXTRA_GTK2_VERSION=.1
 
 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}${EXTRA_RELEASE}${EXTRA_GTK2_VERSION}
index 6917022..0190e93 100644 (file)
 #include "alertpanel.h"
 #include "../inc.h"
 
+enum {
+       PLUGINWINDOW_NAME,              /*<! plugin name */
+       PLUGINWINDOW_DATA,              /*<! Plugin pointer */
+       N_PLUGINWINDOW_COLUMNS
+};
+
 typedef struct _PluginWindow
 {
        GtkWidget *window;
-       GtkWidget *plugin_list;
+       GtkWidget *plugin_list_view;
        GtkWidget *plugin_desc;
        GtkWidget *unload_btn;
 
        Plugin *selected_plugin;
 } PluginWindow;
 
+static GtkListStore* pluginwindow_create_data_store    (void);
+static GtkWidget *pluginwindow_list_view_create                (PluginWindow *pluginwindow);
+static void pluginwindow_create_list_view_columns      (GtkWidget *list_view);
+static gboolean pluginwindow_selected                  (GtkTreeSelection *selector,
+                                                        GtkTreeModel *model, 
+                                                        GtkTreePath *path,
+                                                        gboolean currently_selected,
+                                                        gpointer data);
+
 static void close_cb(GtkButton *button, PluginWindow *pluginwindow)
 {
        gtk_widget_destroy(pluginwindow->window);
@@ -54,15 +69,20 @@ static void close_cb(GtkButton *button, PluginWindow *pluginwindow)
 static void set_plugin_list(PluginWindow *pluginwindow)
 {
        GSList *plugins, *cur;
-       gchar *text[1];
+       const gchar *text;
        gint row;
-       GtkCList *clist = GTK_CLIST(pluginwindow->plugin_list);
+       GtkListStore *store;
+       GtkTreeIter iter;
        GtkTextBuffer *textbuf;
        GtkTextIter start_iter, end_iter;
+       GtkTreeSelection *selection;
 
        plugins = plugin_get_list();
-       gtk_clist_freeze(clist);
-       gtk_clist_clear(clist);
+
+       store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW
+                               (pluginwindow->plugin_list_view)));
+       gtk_list_store_clear(store);
+       
        textbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pluginwindow->plugin_desc));
        gtk_text_buffer_get_start_iter(textbuf, &start_iter);
        gtk_text_buffer_get_end_iter(textbuf, &end_iter);
@@ -72,25 +92,29 @@ static void set_plugin_list(PluginWindow *pluginwindow)
        for(cur = plugins; cur != NULL; cur = g_slist_next(cur)) {
                Plugin *plugin = (Plugin *) cur->data;
 
-               text[0] = (gchar *) plugin_get_name(plugin);
-               row = gtk_clist_append(clist, text);
-               gtk_clist_set_row_data(clist, row, plugin);
+               gtk_list_store_append(store, &iter);
+               text = plugin_get_name(plugin); 
+               gtk_list_store_set(store, &iter,
+                                  PLUGINWINDOW_NAME, text,
+                                  PLUGINWINDOW_DATA, plugin,
+                                  -1);
        }
-       gtk_clist_thaw(clist);
-       if (pluginwindow->selected_plugin == NULL)
-               gtk_clist_select_row (clist, 0, -1);
+
+       if (pluginwindow->selected_plugin == NULL) { 
+               selection = gtk_tree_view_get_selection(GTK_TREE_VIEW
+                               (pluginwindow->plugin_list_view));
+               gtk_tree_selection_unselect_all(selection);                             
+       }               
+       g_slist_free(plugins);
 }
 
-static void select_row_cb(GtkCList *clist, gint row, gint column,
-                         GdkEventButton *event, PluginWindow *pluginwindow)
+static void select_row_cb(Plugin *plugin, PluginWindow *pluginwindow)
 {
-       Plugin *plugin;
        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;
 
-       plugin = (Plugin *) gtk_clist_get_row_data(clist, row);
        pluginwindow->selected_plugin = plugin;
 
        if (pluginwindow->selected_plugin != NULL) {
@@ -105,8 +129,7 @@ static void select_row_cb(GtkCList *clist, gint row, gint column,
        }
 }
 
-static void unselect_row_cb(GtkCList * clist, gint row, gint column,
-                           GdkEventButton * event, PluginWindow *pluginwindow)
+static void unselect_row_cb(Plugin *plugin, PluginWindow *pluginwindow)
 {
        gtk_widget_set_sensitive(pluginwindow->unload_btn, FALSE);      
 }
@@ -135,7 +158,8 @@ static void load_cb(GtkButton *button, PluginWindow *pluginwindow)
                g_free(error);
        }
 
-       set_plugin_list(pluginwindow);          
+       set_plugin_list(pluginwindow);
+       g_free(file);
 }
 
 static gboolean pluginwindow_key_pressed(GtkWidget *widget, GdkEventKey *event,
@@ -175,8 +199,7 @@ void pluginwindow_create()
        GtkWidget *vbox1;
        GtkWidget *hbox2;
        GtkWidget *scrolledwindow2;
-       GtkWidget *plugin_list;
-       GtkWidget *label12;
+       GtkWidget *plugin_list_view;
        GtkWidget *vbox2;
        GtkWidget *frame2;
        GtkWidget *label13;
@@ -186,6 +209,8 @@ void pluginwindow_create()
        GtkWidget *load_btn;
        GtkWidget *unload_btn;
        GtkWidget *close_btn;
+       
+       pluginwindow = g_new0(PluginWindow, 1);
 
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_container_set_border_width(GTK_CONTAINER(window), 8);
@@ -203,25 +228,15 @@ void pluginwindow_create()
 
        scrolledwindow2 = gtk_scrolled_window_new(NULL, NULL);
        gtk_widget_show(scrolledwindow2);
-       gtk_box_pack_start(GTK_BOX(hbox2), scrolledwindow2, TRUE, TRUE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox2), scrolledwindow2, FALSE, FALSE, 0);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW
                                       (scrolledwindow2), GTK_POLICY_NEVER,
-                                      GTK_POLICY_ALWAYS);
+                                      GTK_POLICY_AUTOMATIC);
 
-       plugin_list = gtk_clist_new(1);
-       gtk_widget_show(plugin_list);
-       gtk_container_add(GTK_CONTAINER(scrolledwindow2), plugin_list);
-       gtk_clist_set_column_width(GTK_CLIST(plugin_list), 0, 80);
-       gtk_clist_set_column_auto_resize(GTK_CLIST(plugin_list), 0, TRUE);
-       gtk_clist_column_titles_show(GTK_CLIST(plugin_list));
-       gtk_clist_set_selection_mode(GTK_CLIST (plugin_list), GTK_SELECTION_BROWSE);
-       gtk_widget_grab_focus(GTK_WIDGET(plugin_list));
-
-       label12 = gtk_label_new(_("Plugins"));
-       gtk_widget_show(label12);
-       gtk_clist_set_column_widget(GTK_CLIST(plugin_list), 0, label12);
-       gtk_label_set_justify(GTK_LABEL(label12), GTK_JUSTIFY_LEFT);
-       gtk_misc_set_alignment(GTK_MISC(label12), 0, 0.5);
+       plugin_list_view = pluginwindow_list_view_create(pluginwindow);
+       gtk_widget_show(plugin_list_view);
+       gtk_container_add(GTK_CONTAINER(scrolledwindow2), plugin_list_view);
+       gtk_widget_grab_focus(GTK_WIDGET(plugin_list_view));
 
        vbox2 = gtk_vbox_new(FALSE, 0);
        gtk_widget_show(vbox2);
@@ -265,7 +280,7 @@ void pluginwindow_create()
        gtk_container_add(GTK_CONTAINER(hbuttonbox1), unload_btn);
        GTK_WIDGET_SET_FLAGS(unload_btn, GTK_CAN_DEFAULT);
 
-       close_btn = gtk_button_new_with_label(_("Close"));
+       close_btn = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
        gtk_widget_show(close_btn);
        gtk_container_add(GTK_CONTAINER(hbuttonbox1), close_btn);
        GTK_WIDGET_SET_FLAGS(close_btn, GTK_CAN_DEFAULT);
@@ -274,7 +289,6 @@ void pluginwindow_create()
        gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(plugin_desc), GTK_WRAP_WORD);
        gtk_widget_set_sensitive(GTK_WIDGET(unload_btn), FALSE);
 
-       pluginwindow = g_new0(PluginWindow, 1);
 
        g_signal_connect(G_OBJECT(load_btn), "released",
                         G_CALLBACK(load_cb), pluginwindow);
@@ -282,15 +296,11 @@ 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(plugin_list), "select-row",
-                        G_CALLBACK(select_row_cb), pluginwindow);
-       g_signal_connect(G_OBJECT(plugin_list), "unselect-row",
-                        G_CALLBACK(unselect_row_cb), pluginwindow);
        g_signal_connect(G_OBJECT(window), "key_press_event",
                           G_CALLBACK(pluginwindow_key_pressed), pluginwindow);
 
        pluginwindow->window = window;
-       pluginwindow->plugin_list = plugin_list;
+       pluginwindow->plugin_list_view = plugin_list_view;
        pluginwindow->plugin_desc = plugin_desc;
        pluginwindow->unload_btn = unload_btn;
        pluginwindow->selected_plugin = NULL;
@@ -300,3 +310,73 @@ void pluginwindow_create()
        inc_lock();
        gtk_widget_show(window);
 }
+
+static GtkListStore* pluginwindow_create_data_store(void)
+{
+       return gtk_list_store_new(N_PLUGINWINDOW_COLUMNS,
+                                 G_TYPE_STRING,        
+                                 G_TYPE_POINTER,
+                                 -1);
+}
+
+static GtkWidget *pluginwindow_list_view_create(PluginWindow *pluginwindow)
+{
+       GtkTreeView *list_view;
+       GtkTreeSelection *selector;
+       GtkTreeModel *model;
+
+       model = GTK_TREE_MODEL(pluginwindow_create_data_store());
+       list_view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(model));
+       g_object_unref(model);  
+       
+       gtk_tree_view_set_rules_hint(list_view, TRUE);
+       
+       selector = gtk_tree_view_get_selection(list_view);
+       gtk_tree_selection_set_mode(selector, GTK_SELECTION_BROWSE);
+       gtk_tree_selection_set_select_function(selector, pluginwindow_selected,
+                                              pluginwindow, NULL);
+
+       /* create the columns */
+       pluginwindow_create_list_view_columns(GTK_WIDGET(list_view));
+
+       return GTK_WIDGET(list_view);
+}
+
+static void pluginwindow_create_list_view_columns(GtkWidget *list_view)
+{
+       GtkTreeViewColumn *column;
+       GtkCellRenderer *renderer;
+
+       renderer = gtk_cell_renderer_text_new();
+       column = gtk_tree_view_column_new_with_attributes
+               (_("Plugins"),
+                renderer,
+                "text", PLUGINWINDOW_NAME,
+                NULL);
+       gtk_tree_view_append_column(GTK_TREE_VIEW(list_view), column);          
+}
+
+static gboolean pluginwindow_selected(GtkTreeSelection *selector,
+                                     GtkTreeModel *model, 
+                                     GtkTreePath *path,
+                                     gboolean currently_selected,
+                                     gpointer data)
+{
+       GtkTreeIter iter;
+       Plugin *plugin;
+       
+       if (!gtk_tree_model_get_iter(model, &iter, path))
+               return TRUE;
+
+       gtk_tree_model_get(model, &iter, 
+                          PLUGINWINDOW_DATA, &plugin,
+                          -1);
+
+       if (currently_selected) 
+               unselect_row_cb(plugin, data);
+       else
+               select_row_cb(plugin, data);
+
+       return TRUE;
+}
+