[Commits] [SCM] claws branch, master, updated. 3.16.0-77-g4c168ab

ticho at claws-mail.org ticho at claws-mail.org
Tue Feb 27 20:21:27 CET 2018


The branch, master has been updated
       via  4c168abbad5d0e4f50735e1c380d05596c7af222 (commit)
      from  b357c3b93e69f90077bfb7c3884b91e5c0ac45e1 (commit)

Summary of changes:
 src/gtk/gtkutils.c |   15 +++++++++++++--
 src/gtk/gtkutils.h |   10 ++++++++--
 2 files changed, 21 insertions(+), 4 deletions(-)


- Log -----------------------------------------------------------------
commit 4c168abbad5d0e4f50735e1c380d05596c7af222
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Tue Feb 27 20:19:37 2018 +0100

    Make the gtkut_tree_view_get_selected_pointer() more versatile.
    
    It can now be used also for non-trivial use cases, where
    the caller needs to further work with the model and/or
    selection, or if a string value needs to be read from the
    model.

diff --git a/src/gtk/gtkutils.c b/src/gtk/gtkutils.c
index 689af37..47b76df 100644
--- a/src/gtk/gtkutils.c
+++ b/src/gtk/gtkutils.c
@@ -1991,12 +1991,14 @@ gboolean auto_configure_service_sync(const gchar *service, const gchar *domain,
 #endif
 
 gpointer gtkut_tree_view_get_selected_pointer(GtkTreeView *view,
-		gint column)
+		gint column, GtkTreeModel **_model, GtkTreeSelection **_selection,
+		GtkTreeIter *_iter)
 {
 	GtkTreeIter iter;
 	GtkTreeModel *model;
 	GtkTreeSelection *sel;
 	gpointer ptr;
+	GType type;
 
 	cm_return_val_if_fail(view != NULL, NULL);
 	cm_return_val_if_fail(column >= 0, NULL);
@@ -2013,11 +2015,20 @@ gpointer gtkut_tree_view_get_selected_pointer(GtkTreeView *view,
 	cm_return_val_if_fail(
 			gtk_tree_model_get_n_columns(model) > column,
 			NULL);
+
+	type = gtk_tree_model_get_column_type(model, column);
 	cm_return_val_if_fail(
-			gtk_tree_model_get_column_type(model, column) == G_TYPE_POINTER,
+			type == G_TYPE_POINTER || type == G_TYPE_STRING,
 			NULL);
 
 	gtk_tree_model_get(model, &iter, column, &ptr, -1);
 
+	if (_model != NULL)
+		*_model = model;
+	if (_selection != NULL)
+		*_selection = sel;
+	if (_iter != NULL)
+		*_iter = iter;
+
 	return ptr;
 }
diff --git a/src/gtk/gtkutils.h b/src/gtk/gtkutils.h
index eaf0fb0..592e575 100644
--- a/src/gtk/gtkutils.h
+++ b/src/gtk/gtkutils.h
@@ -233,9 +233,15 @@ gboolean auto_configure_service_sync(const gchar *service, const gchar *domain,
 #endif
 
 /* Returns pointer stored in selected row of a tree view's model
- * in a given column. The column has to be of type G_TYPE_POINTER. */
+ * in a given column. The column has to be of type G_TYPE_POINTER
+ * or G_TYPE_STRING (in this case, the returned value has to be
+ * freed by the caller.
+ * _model, _selection and _iter parameters are optional, and if
+ * not NULL, they will be set to point to corresponding GtkTreeModel,
+ * GtkTreeSelection, and GtkTreeIter of the selected row. */
 gpointer gtkut_tree_view_get_selected_pointer(GtkTreeView *view,
-		gint column);
+		gint column, GtkTreeModel **_model, GtkTreeSelection **_selection,
+		GtkTreeIter *_iter);
 
 #if GTK_CHECK_VERSION (3, 2, 0)
 #define GTK_TYPE_VBOX GTK_TYPE_BOX

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list