[Commits] [SCM] claws branch, gtk3, updated. 3.16.0-99-g0fc50c6

ticho at claws-mail.org ticho at claws-mail.org
Sat Feb 24 23:32:49 CET 2018


The branch, gtk3 has been updated
       via  0fc50c6f862b45e2a8675a6ba13bffde926f1981 (commit)
       via  19775d9e05bbb566d8afad3d3f82d8d0fd1129e4 (commit)
       via  0ab939b04daec46d7bf2408b31c3732b0f337fbf (commit)
      from  6638b884b84f30f6e31f50179261af0878ee010e (commit)

Summary of changes:
 src/addrcustomattr.c                    |   10 ++-
 src/addressadd.c                        |    1 +
 src/addrgather.c                        |    1 +
 src/editldap_basedn.c                   |  102 ++++++++++++++++++++++---------
 src/edittags.c                          |    7 ++-
 src/gtk/foldersort.c                    |    1 +
 src/gtk/gtkutils.c                      |    2 +
 src/importldif.c                        |    1 +
 src/mimeview.c                          |    1 +
 src/plugins/managesieve/sieve_manager.c |    5 +-
 src/plugins/pdf_viewer/poppler_viewer.c |    2 +
 src/plugins/pgpcore/select-keys.c       |    1 +
 src/prefs_filtering.c                   |   12 ++--
 src/prefs_send.c                        |    4 ++
 src/prefs_summaries.c                   |    1 +
 src/prefs_toolbar.c                     |   13 +++-
 16 files changed, 128 insertions(+), 36 deletions(-)


- Log -----------------------------------------------------------------
commit 0fc50c6f862b45e2a8675a6ba13bffde926f1981
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Sat Feb 24 23:27:35 2018 +0100

    Fix memory leaks from results of gtk_tree_model_get().
    
    G_TYPE_STRING values need to be freed, G_TYPE_PIXBUF
    (or anything else derived from GObject) needs to be
    unreferenced. This was forgotten in some places.

diff --git a/src/addrcustomattr.c b/src/addrcustomattr.c
index 5cb6475..97d7293 100644
--- a/src/addrcustomattr.c
+++ b/src/addrcustomattr.c
@@ -102,6 +102,7 @@ static gint custom_attr_cmp_func (GtkTreeModel *model, GtkTreeIter *a,
 								  GtkTreeIter *b, gpointer userdata)
  {
 	gchar *name1, *name2;
+	gint res;
 
 	gtk_tree_model_get(model, a, CUSTOM_ATTR_NAME, &name1, -1);
 	gtk_tree_model_get(model, b, CUSTOM_ATTR_NAME, &name2, -1);
@@ -112,7 +113,11 @@ static gint custom_attr_cmp_func (GtkTreeModel *model, GtkTreeIter *a,
 	if (name2 == NULL)
 		return 1;
 	
-	return g_utf8_collate(name1, name2);
+	res = g_utf8_collate(name1, name2);
+	g_free(name1);
+	g_free(name2);
+
+	return res;
 }
 
 static GtkListStore* custom_attr_window_create_data_store(void)
@@ -346,8 +351,10 @@ static gboolean find_attr_in_store(GtkTreeModel *model,
 	if (g_utf8_collate(data->attr, attr)==0) {
 		data->path = path; /* signal we found it */
 		data->iter = *iter;
+		g_free(attr);
 		return TRUE;
 	}
+	g_free(attr);
 	return FALSE; 
 }
 
@@ -579,6 +586,7 @@ static gboolean custom_attr_store_to_glist (GtkTreeModel *model,
 	gtk_tree_model_get(model, iter, CUSTOM_ATTR_NAME, &attr, -1);
 	if (attr) {
 		store_to_glist = g_list_prepend(store_to_glist, g_strdup(attr));
+		g_free(attr);
 	}
 	return FALSE;
 }
diff --git a/src/edittags.c b/src/edittags.c
index 2169ade..8f2bac2 100644
--- a/src/edittags.c
+++ b/src/edittags.c
@@ -58,6 +58,7 @@ enum {
 static gint tag_cmp_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata)
  {
 	gchar *name1, *name2;
+	gint res;
 
 	gtk_tree_model_get(model, a, TAG_NAME, &name1, -1);
 	gtk_tree_model_get(model, b, TAG_NAME, &name2, -1);
@@ -68,7 +69,11 @@ static gint tag_cmp_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, g
 	if (name2 == NULL)
 		return 1;
 	
-	return g_utf8_collate(name1,name2);
+	res = g_utf8_collate(name1,name2);
+	g_free(name1);
+	g_free(name2);
+
+	return res;
 }
 
 static void apply_window_create(void);
diff --git a/src/gtk/gtkutils.c b/src/gtk/gtkutils.c
index 203aec7..f390f2f 100644
--- a/src/gtk/gtkutils.c
+++ b/src/gtk/gtkutils.c
@@ -1508,12 +1508,14 @@ gboolean gtkut_tree_model_text_iter_prev(GtkTreeModel *model,
 		gtk_tree_model_get(model, &cur_iter, 0, &cur_value, -1);
 
 		if (strcmp(text, cur_value) == 0) {
+			g_free(cur_value);
 			if (count <= 0)
 				return FALSE;
 
 			return gtk_tree_model_iter_nth_child(model, iter, NULL, count - 1);
 		}
 
+		g_free(cur_value);
 		valid = gtk_tree_model_iter_next(model, &cur_iter);
 		count++;
 	}
diff --git a/src/plugins/managesieve/sieve_manager.c b/src/plugins/managesieve/sieve_manager.c
index 7635c8b..8a9af4c 100644
--- a/src/plugins/managesieve/sieve_manager.c
+++ b/src/plugins/managesieve/sieve_manager.c
@@ -186,11 +186,12 @@ static void filter_edit(GtkWidget *widget, SieveManagerPage *page)
 {
 	SieveEditorPage *editor;
 	SieveSession *session = page->active_session;
+	gchar *filter_name;
 
 	if (!session)
 		return;
 
-	gchar *filter_name = filters_list_get_selected_filter(page->filters_list);
+	filter_name = filters_list_get_selected_filter(page->filters_list);
 	if (!filter_name)
 		return;
 
@@ -202,6 +203,8 @@ static void filter_edit(GtkWidget *widget, SieveManagerPage *page)
 		sieve_editor_load(editor,
 			(sieve_session_cb_fn)filter_got_load_error, page);
 	}
+
+	g_free(filter_name);
 }
 
 static void filter_renamed(SieveSession *session, gboolean abort,
diff --git a/src/prefs_filtering.c b/src/prefs_filtering.c
index 96927d5..6f27e03 100644
--- a/src/prefs_filtering.c
+++ b/src/prefs_filtering.c
@@ -956,7 +956,6 @@ static void prefs_filtering_set_list(void)
 					filtering.cond_list_view, row,
 					&enabled, &name, &account_id);
 			prop = matcher_parser_get_filtering(filtering_str);
-			g_free(filtering_str);
 			if (prop) {
 				prop->enabled = enabled;
 				if (prop->name != NULL)
@@ -967,7 +966,8 @@ static void prefs_filtering_set_list(void)
 					g_slist_append(prefs_filtering, prop);
 			}
 		}
-		
+
+		g_free(filtering_str);
 		row++;
 	}				
 	
@@ -1182,6 +1182,7 @@ static void prefs_filtering_substitute_cb(gpointer action, gpointer data)
 	prefs_filtering_list_view_get_rule_info(
 			filtering.cond_list_view, selected_row,
 			&enabled, &name, &account_id);
+	g_free(name); /* We're not using this. */
 	prop->enabled = enabled;
 
 	prefs_filtering_list_view_set_row(selected_row, prop);
@@ -1262,6 +1263,7 @@ static void prefs_filtering_duplicate_cb(gpointer action, gpointer data)
 	prefs_filtering_list_view_get_rule_info(
 			filtering.cond_list_view, selected_row,
 			&enabled, &name, &account_id);
+	g_free(name); /* We're not using this. */
 	prop->enabled = enabled;
 
 	prefs_filtering_list_view_set_row(-selected_row-2, prop);
diff --git a/src/prefs_send.c b/src/prefs_send.c
index 41bd4b1..ab3307e 100644
--- a/src/prefs_send.c
+++ b/src/prefs_send.c
@@ -91,9 +91,11 @@ static gboolean _select_by_data_func(GtkTreeModel *model, GtkTreePath *path,
 	gtk_tree_model_get(GTK_TREE_MODEL(model), iter, COMBOBOX_DATA, &curdata, -1);
 	if ( data != NULL && curdata != NULL && !strcmp(data, curdata) ) {
 		gtk_combo_box_set_active_iter(combobox, iter);
+		g_free(curdata);
 		return TRUE;
 	}
 
+	g_free(curdata);
 	return FALSE;
 }
 
@@ -126,6 +128,8 @@ static gboolean _combobox_separator_func(GtkTreeModel *model,
 
 	if( txt == NULL )
 		return TRUE;
+
+	g_free(txt);
 	return FALSE;
 }
 
diff --git a/src/prefs_summaries.c b/src/prefs_summaries.c
index 7a78d99..2e17df2 100644
--- a/src/prefs_summaries.c
+++ b/src/prefs_summaries.c
@@ -889,6 +889,7 @@ static void date_format_select_row(GtkTreeView *list_view,
 	strncpy(new_format, old_format, cur_pos);
 	new_format[cur_pos] = '\0';
 	strcat(new_format, format);
+	g_free(format);
 	strcat(new_format, &old_format[cur_pos]);
 
 	gtk_entry_set_text(GTK_ENTRY(datefmt_sample), new_format);
diff --git a/src/prefs_toolbar.c b/src/prefs_toolbar.c
index 50293b3..03adca3 100644
--- a/src/prefs_toolbar.c
+++ b/src/prefs_toolbar.c
@@ -1319,7 +1319,8 @@ static void set_visible_if_not_text(GtkTreeViewColumn *col,
 				   -1);
 		/* note getting a pixbuf from a tree model increases
 		 * its refcount ... */
-		g_object_unref(pixbuf);
+		if (pixbuf != NULL)
+			g_object_unref(pixbuf);
 
 		g_object_set(renderer, "visible", TRUE, NULL);
 		g_object_set(renderer, "pixbuf",  pixbuf, NULL);
@@ -1437,6 +1438,8 @@ static gboolean set_list_selected(GtkTreeSelection *selector,
 					ITEM_SEPARATOR);
 		g_free(icon_text);
 		g_free(descr);
+		if (pix != NULL)
+			g_object_unref(pix);
 
 		return TRUE;
 	}
@@ -1473,6 +1476,8 @@ static gboolean set_list_selected(GtkTreeSelection *selector,
 
 		g_free(icon_text);
 		g_free(descr);
+		if (pix != NULL)
+			g_object_unref(pix);
 
 		return TRUE;
 	}
@@ -1488,6 +1493,8 @@ static gboolean set_list_selected(GtkTreeSelection *selector,
 
 		g_free(descr);
 		g_free(icon_text);
+		if (pix != NULL)
+			g_object_unref(pix);
 		return TRUE;
 	}
 
@@ -1513,6 +1520,8 @@ static gboolean set_list_selected(GtkTreeSelection *selector,
 
 	g_free(icon_text);
 	g_free(descr);
+	if (pix != NULL)
+		g_object_unref(pix);
 
 	return TRUE;
 }
@@ -1548,6 +1557,8 @@ static void icon_chooser_ok_clicked(GtkButton *button,
 	prefs_toolbar->item_icon_file = icon_file;
 	gtk_button_set_image(GTK_BUTTON(prefs_toolbar->icon_button),
 			     gtk_image_new_from_pixbuf(pix));
+	if (pix != NULL)
+		g_object_unref(pix);
 
 	gtk_widget_destroy(prefs_toolbar->icon_chooser_win);
 	prefs_toolbar->icon_chooser_win = NULL;

commit 19775d9e05bbb566d8afad3d3f82d8d0fd1129e4
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Sat Feb 24 22:30:51 2018 +0100

    Unreference GtkTreeModel pointers after they've been added to a tree view.
    
    This was forgotten in only a few cases.

diff --git a/src/addressadd.c b/src/addressadd.c
index 244e010..78aea88 100644
--- a/src/addressadd.c
+++ b/src/addressadd.c
@@ -271,6 +271,7 @@ static void addressadd_create( void ) {
 			GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_POINTER);
 
 	tree_folder = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
+	g_object_unref(store);
 	gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree_folder), TRUE);
 	gtk_tree_view_set_enable_tree_lines(GTK_TREE_VIEW(tree_folder), FALSE);
 	gtk_tree_view_set_search_column(GTK_TREE_VIEW(tree_folder),
diff --git a/src/addrgather.c b/src/addrgather.c
index efdb1eb..dc646fc 100644
--- a/src/addrgather.c
+++ b/src/addrgather.c
@@ -481,6 +481,7 @@ static void addrgather_page_finish( gint pageNum, gchar *pageLbl ) {
 			G_TYPE_STRING, G_TYPE_STRING, -1));
 
 	viewCount = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+	g_object_unref(model);
 	gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(viewCount), TRUE);
 	gtk_tree_view_set_reorderable(GTK_TREE_VIEW(viewCount), FALSE);
 	sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(viewCount));
diff --git a/src/editldap_basedn.c b/src/editldap_basedn.c
index 08e0f24..8d7932c 100644
--- a/src/editldap_basedn.c
+++ b/src/editldap_basedn.c
@@ -216,6 +216,7 @@ static void edit_ldap_bdn_create(void) {
 	store = gtk_list_store_new(1, G_TYPE_STRING, -1);
 
 	basedn_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
+	g_object_unref(store);
 	gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(basedn_list), TRUE);
 	sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(basedn_list));
 	gtk_tree_selection_set_mode(sel, GTK_SELECTION_BROWSE);
diff --git a/src/gtk/foldersort.c b/src/gtk/foldersort.c
index 79f85a8..8160235 100644
--- a/src/gtk/foldersort.c
+++ b/src/gtk/foldersort.c
@@ -295,6 +295,7 @@ void foldersort_open()
 
 	/* Create the view widget */
 	folderlist = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
+	g_object_unref(store);
 	gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(folderlist), TRUE);
 	gtk_tree_view_set_reorderable(GTK_TREE_VIEW(folderlist), TRUE);
 	selector = gtk_tree_view_get_selection(GTK_TREE_VIEW(folderlist));
diff --git a/src/importldif.c b/src/importldif.c
index 151ef1b..86ea2dd 100644
--- a/src/importldif.c
+++ b/src/importldif.c
@@ -700,6 +700,7 @@ static void imp_ldif_page_fields( gint pageNum, gchar *pageLbl ) {
 			-1);
 
 	view_fields = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
+	g_object_unref(store);
 	gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view_fields), TRUE);
 	gtk_tree_view_set_reorderable(GTK_TREE_VIEW(view_fields), FALSE);
 	sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(view_fields));
diff --git a/src/mimeview.c b/src/mimeview.c
index 7201ac9..8fa8cd3 100644
--- a/src/mimeview.c
+++ b/src/mimeview.c
@@ -287,6 +287,7 @@ MimeView *mimeview_create(MainWindow *mainwin)
 				   G_TYPE_POINTER);
 
 	ctree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+	g_object_unref(model);
 	gtk_tree_view_set_enable_search(GTK_TREE_VIEW(ctree), FALSE);
 	gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(ctree),
 					prefs_common.use_stripes_everywhere);
diff --git a/src/plugins/pdf_viewer/poppler_viewer.c b/src/plugins/pdf_viewer/poppler_viewer.c
index d04ee49..ed2934f 100644
--- a/src/plugins/pdf_viewer/poppler_viewer.c
+++ b/src/plugins/pdf_viewer/poppler_viewer.c
@@ -1824,6 +1824,8 @@ static MimeViewer *pdf_viewer_create(void)
 					G_TYPE_DOUBLE);
 
 	viewer->index_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(tree_store));
+	g_object_unref(tree_store);
+
 	renderer = gtk_cell_renderer_text_new();
 	column = gtk_tree_view_column_new_with_attributes(_("Name"),  renderer, "text", 0,  NULL);
 	gtk_tree_view_append_column(GTK_TREE_VIEW(viewer->index_list), column);		
diff --git a/src/plugins/pgpcore/select-keys.c b/src/plugins/pgpcore/select-keys.c
index 407d7c2..f558f6b 100644
--- a/src/plugins/pgpcore/select-keys.c
+++ b/src/plugins/pgpcore/select-keys.c
@@ -454,6 +454,7 @@ create_dialog (struct select_keys_s *sk)
 				-1);
 
 		view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
+		g_object_unref(store);
 		gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), TRUE);
 		gtk_tree_view_set_reorderable(GTK_TREE_VIEW(view), FALSE);
 		sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
diff --git a/src/prefs_filtering.c b/src/prefs_filtering.c
index e475346..96927d5 100644
--- a/src/prefs_filtering.c
+++ b/src/prefs_filtering.c
@@ -1797,9 +1797,11 @@ static GtkWidget *prefs_filtering_list_view_create(void)
 {
 	GtkTreeView *list_view;
 	GtkTreeSelection *selector;
+	GtkListStore *store = prefs_filtering_create_data_store();
 
-	list_view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(GTK_TREE_MODEL
-		(prefs_filtering_create_data_store())));
+	list_view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(
+				GTK_TREE_MODEL(store)));
+	g_object_unref(store);
 #ifdef GENERIC_UMPC
 	g_object_set(list_view, "allow-checkbox-mode", FALSE, NULL);
 #endif

commit 0ab939b04daec46d7bf2408b31c3732b0f337fbf
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Sat Feb 24 22:14:25 2018 +0100

    Replace GtkCMCList in editldap_basedn.c with GtkTreeView.

diff --git a/src/editldap_basedn.c b/src/editldap_basedn.c
index b7a4484..08e0f24 100644
--- a/src/editldap_basedn.c
+++ b/src/editldap_basedn.c
@@ -91,25 +91,44 @@ static void edit_ldap_bdn_cancel( GtkWidget *widget, gboolean *cancelled ) {
 	gtk_main_quit();
 }
 
-static void edit_ldap_bdn_list_select( GtkCMCList *clist, gint row, gint column, GdkEvent *event, gpointer data ) {
-	gchar *text = NULL;
+static void set_selected()
+{
+	GtkWidget *entry = ldapedit_basedn.basedn_entry;
+	GtkWidget *view = ldapedit_basedn.basedn_list;
+	GtkTreeModel *model;
+	GtkTreeSelection *sel;
+	GtkTreeIter iter;
+	gchar *text;
 
-	if( gtk_cmclist_get_text( clist, row, 0, &text ) ) {
-		if( text ) {
-			gtk_entry_set_text(GTK_ENTRY(ldapedit_basedn.basedn_entry), text );
-		}
-	}
+	if (entry == NULL || view == NULL)
+		return;
+
+	sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
+	if (!gtk_tree_selection_get_selected(sel, &model, &iter))
+		return;
+
+	gtk_tree_model_get(model, &iter, 0, &text, -1);
+
+	if (text == NULL)
+		return;
+
+	gtk_entry_set_text(GTK_ENTRY(entry), text);
+	g_free(text);
 }
 
-static gboolean edit_ldap_bdn_list_button( GtkCMCList *clist, GdkEventButton *event, gpointer data ) {
-	if( ! event ) return FALSE;
-	if( event->button == 1 ) {
-		if( event->type == GDK_2BUTTON_PRESS ) {
-			ldapedit_basedn_cancelled = FALSE;
-			gtk_main_quit();
-		}
-	}
-	return FALSE;
+static void basedn_list_cursor_changed(GtkTreeView *view,
+		gpointer user_data)
+{
+	set_selected();
+}
+
+static void basedn_list_row_activated(GtkTreeView *view,
+		GtkTreePath *path,
+		GtkTreeViewColumn *column,
+		gpointer user_data)
+{
+	set_selected();
+	edit_ldap_bdn_ok(NULL, NULL);
 }
 
 static void edit_ldap_bdn_create(void) {
@@ -130,6 +149,10 @@ static void edit_ldap_bdn_create(void) {
 	GtkWidget *hsbox;
 	GtkWidget *statusbar;
 	gint top;
+	GtkListStore *store;
+	GtkTreeSelection *sel;
+	GtkTreeViewColumn *col;
+	GtkCellRenderer *rdr;
 
 	window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "editldap_basedn");
 	gtk_container_set_border_width(GTK_CONTAINER(window), 0);
@@ -190,11 +213,26 @@ static void edit_ldap_bdn_create(void) {
 				       GTK_POLICY_AUTOMATIC);
 	gtk_box_pack_start(GTK_BOX(vlbox), lwindow, TRUE, TRUE, 0);
 
-	basedn_list = gtk_cmclist_new(1);
+	store = gtk_list_store_new(1, G_TYPE_STRING, -1);
+
+	basedn_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
+	gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(basedn_list), TRUE);
+	sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(basedn_list));
+	gtk_tree_selection_set_mode(sel, GTK_SELECTION_BROWSE);
+
+	rdr = gtk_cell_renderer_text_new();
+	col = gtk_tree_view_column_new_with_attributes(
+			_("Available Search Base(s)"), rdr,
+			"markup", 0, NULL);
+	gtk_tree_view_append_column(GTK_TREE_VIEW(basedn_list), col);
+
 	gtk_container_add(GTK_CONTAINER(lwindow), basedn_list);
-	gtk_cmclist_column_titles_show( GTK_CMCLIST(basedn_list) );
-	gtk_cmclist_set_column_title( GTK_CMCLIST(basedn_list), 0, _( "Available Search Base(s)" ) );
-	gtk_cmclist_set_selection_mode(GTK_CMCLIST(basedn_list), GTK_SELECTION_BROWSE);
+
+	g_signal_connect(G_OBJECT(basedn_list), "cursor-changed",
+			G_CALLBACK(basedn_list_cursor_changed), NULL);
+	g_signal_connect(G_OBJECT(basedn_list), "row-activated",
+			G_CALLBACK(basedn_list_row_activated), NULL);
+
 
 	/* Status line */
 	hsbox = gtk_hbox_new(FALSE, 0);
@@ -217,10 +255,6 @@ static void edit_ldap_bdn_create(void) {
 			 G_CALLBACK(edit_ldap_bdn_ok), NULL);
 	g_signal_connect(G_OBJECT(cancel_btn), "clicked",
 			 G_CALLBACK(edit_ldap_bdn_cancel), NULL);
-	g_signal_connect(G_OBJECT(basedn_list), "select_row",
-			 G_CALLBACK(edit_ldap_bdn_list_select), NULL);
-	g_signal_connect(G_OBJECT(basedn_list), "button_press_event",
-			 G_CALLBACK(edit_ldap_bdn_list_button), NULL);
 
 	gtk_widget_show_all(vbox);
 
@@ -247,9 +281,15 @@ static void edit_ldap_bdn_load_data(
 	gboolean flgConn;
 	gboolean flgDN;
 	GList *baseDN = NULL;
+	GtkWidget *view = ldapedit_basedn.basedn_list;
+	GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
+	GtkTreeIter iter;
+	GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
 
 	edit_ldap_bdn_status_show( "" );
-	gtk_cmclist_clear(GTK_CMCLIST(ldapedit_basedn.basedn_list));
+
+	gtk_list_store_clear(GTK_LIST_STORE(model));
+
 	ldapedit_basedn_bad_server = TRUE;
 	flgConn = flgDN = FALSE;
 	sHost = g_strdup( hostName );
@@ -263,14 +303,19 @@ static void edit_ldap_bdn_load_data(
 			baseDN = ldaputil_read_basedn( sHost, iPort, bindDN, bindPW, tov, ssl, tls );
 			if( baseDN ) {
 				GList *node = baseDN;
-				gchar *text[2] = { NULL, NULL };
 
 				while( node ) {
-					text[0] = (gchar *)node->data;
-					gtk_cmclist_append(GTK_CMCLIST(ldapedit_basedn.basedn_list), text);
+					gtk_list_store_append(GTK_LIST_STORE(model), &iter);
+					gtk_list_store_set(GTK_LIST_STORE(model), &iter,
+							0, (gchar *)node->data, -1);
 					node = g_list_next( node );
 					flgDN = TRUE;
 				}
+
+				/* Select the first line */
+				if (gtk_tree_model_get_iter_first(model, &iter))
+					gtk_tree_selection_select_iter(sel, &iter);
+
 				mgu_free_dlist( baseDN );
 				baseDN = node = NULL;
 			}

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list