changeset 31845:63fb41aa3dbe

Add API: * purple_notify_searchresult_column_set_visible * purple_notify_searchresult_column_is_visible This allows columns to be defined in the search-results, but that are not visible to the user. These columns can, for example, be used to store values associated with the selected-row that are required in the search-result callback.
author andrew.victor@mxit.com
date Tue, 03 May 2011 20:55:39 +0000
parents 3448f64d197c
children a88631af0f5e
files ChangeLog.API finch/gntnotify.c libpurple/notify.c libpurple/notify.h pidgin/gtknotify.c
diffstat 5 files changed, 46 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog.API	Mon Apr 18 07:02:43 2011 +0000
+++ b/ChangeLog.API	Tue May 03 20:55:39 2011 +0000
@@ -2,6 +2,10 @@
 
 version 3.0.0 (??/??/????):
 	libpurple:
+		Added:
+		* purple_notify_searchresult_column_set_visible
+		* purple_notify_searchresult_column_is_visible
+
 		Removed:
 		* purple_core_migrate
 
--- a/finch/gntnotify.c	Mon Apr 18 07:02:43 2011 +0000
+++ b/finch/gntnotify.c	Tue May 03 20:55:39 2011 +0000
@@ -426,6 +426,9 @@
 	{
 		PurpleNotifySearchColumn *column = iter->data;
 		gnt_tree_set_column_title(GNT_TREE(tree), i, column->title);
+
+		if (!purple_notify_searchresult_column_is_visible(column))
+			gnt_tree_set_column_visible(GNT_TREE(tree), i, FALSE);
 		i++;
 	}
 
--- a/libpurple/notify.c	Mon Apr 18 07:02:43 2011 +0000
+++ b/libpurple/notify.c	Tue May 03 20:55:39 2011 +0000
@@ -363,10 +363,26 @@
 
 	sc = g_new0(PurpleNotifySearchColumn, 1);
 	sc->title = g_strdup(title);
+	sc->visible = TRUE;
 
 	return sc;
 }
 
+void purple_notify_searchresult_column_set_visible(PurpleNotifySearchColumn *column, gboolean visible)
+{
+	g_return_if_fail(column != NULL);
+
+	column->visible = visible;
+}
+
+gboolean
+purple_notify_searchresult_column_is_visible(const PurpleNotifySearchColumn *column)
+{
+	g_return_val_if_fail(column != NULL, FALSE);
+
+	return column->visible;
+}
+
 guint
 purple_notify_searchresults_get_columns_count(PurpleNotifySearchResults *results)
 {
--- a/libpurple/notify.h	Mon Apr 18 07:02:43 2011 +0000
+++ b/libpurple/notify.h	Tue May 03 20:55:39 2011 +0000
@@ -111,7 +111,8 @@
  */
 typedef struct
 {
-	char *title; /**< Title of the column. */
+	char *title;           /**< Title of the column. */
+	gboolean visible;
 
 } PurpleNotifySearchColumn;
 
@@ -275,6 +276,23 @@
 PurpleNotifySearchColumn *purple_notify_searchresults_column_new(const char *title);
 
 /**
+ * Sets whether or not a search result column is visible.
+ *
+ * @param field   The search column object.
+ * @param visible TRUE if visible, or FALSE if not.
+ */
+void purple_notify_searchresult_column_set_visible(PurpleNotifySearchColumn *column, gboolean visible);
+
+/**
+ * Returns whether or not a search result column is visible.
+ *
+ * @param field The search column object.
+ *
+ * @return TRUE if the search result column is visible. FALSE otherwise.
+ */
+gboolean purple_notify_searchresult_column_is_visible(const PurpleNotifySearchColumn *column);
+
+/**
  * Adds a new column to the search result object.
  *
  * @param results The result object to which the column will be added.
--- a/pidgin/gtknotify.c	Mon Apr 18 07:02:43 2011 +0000
+++ b/pidgin/gtknotify.c	Tue May 03 20:55:39 2011 +0000
@@ -1035,6 +1035,10 @@
 
 		gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), -1,
 				column->title, renderer, "text", i, NULL);
+
+		if (!purple_notify_searchresult_column_is_visible(column))
+			gtk_tree_view_column_set_visible(gtk_tree_view_get_column(GTK_TREE_VIEW(treeview), i), FALSE);
+
 		i++;
 	}