purple_notify_searchresult_column visibility

Andrew Victor avictor.za at gmail.com
Tue Mar 29 16:44:39 EDT 2011


hi,

You might want to store values within each row of a search-result, but
not have those values visible to the user.
eg,  an internal UserId to be used in the SearchResult callback.

This patch adds API:
  void purple_notify_searchresult_column_set_visible(PurpleNotifySearchColumn
*column, gboolean visible);
  gboolean purple_notify_searchresult_column_is_visible(const
PurpleNotifySearchColumn *column)

Updates Pidgin and Finch to change UI visibility of those columns.

Yes / No ?

Regards,
 Andrew Victor


============================================================
--- finch/gntnotify.c	0aa0b8de803020f52b66b32047a50d406d87840e
+++ finch/gntnotify.c	cffbae7cf0afa70881634069ddf55aaa1320905e
@@ -426,6 +426,9 @@ finch_notify_searchresults(PurpleConnect
 	{
 		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++;
 	}

============================================================
--- libpurple/notify.c	7110d5940b0743e117730aebc9f3e18a2e8c959c
+++ libpurple/notify.c	f82c218ffc860dd5a6e862b98a5e776d793afe4e
@@ -363,10 +363,26 @@ purple_notify_searchresults_column_new(c

 	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)
 {
============================================================
--- libpurple/notify.h	37a8aa775ee077a7770b0917d10576d62256f8cd
+++ libpurple/notify.h	c2af7b6a96b897070b614b81e7e8950d9d0109db
@@ -111,7 +111,8 @@ typedef struct
  */
 typedef struct
 {
-	char *title; /**< Title of the column. */
+	char *title;           /**< Title of the column. */
+	gboolean visible;

 } PurpleNotifySearchColumn;

@@ -275,6 +276,23 @@ PurpleNotifySearchColumn *purple_notify_
 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.
============================================================
--- libpurple/protocols/mxit/profile.c	13b0ac2a3e3ca34146855046a8c8d9486e811e4d
+++ libpurple/protocols/mxit/profile.c	085011f05038dfe52dbda045343f50794591158d
@@ -244,6 +244,7 @@ void mxit_show_search_results( struct MX

 	/* define columns */
 	column = purple_notify_searchresults_column_new( _( "UserId" ) );
+	purple_notify_searchresult_column_set_visible( column, FALSE );
 	purple_notify_searchresults_column_add( results, column );
 	column = purple_notify_searchresults_column_new( _( "Display Name" ) );
 	purple_notify_searchresults_column_add( results, column );
============================================================
--- pidgin/gtknotify.c	06c15f794dd070d35181720e0cf03dd3fd49bf25
+++ pidgin/gtknotify.c	35a2e52a99011cc21a0cbb06f3b9bab30a727765
@@ -1035,6 +1035,10 @@ pidgin_notify_searchresults(PurpleConnec

 		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++;
 	}




More information about the Devel mailing list