pidgin.next.major: b76ceb5b: Add API: purple_request_field_set_toolti...

andrew.victor at mxit.com andrew.victor at mxit.com
Tue May 3 17:25:27 EDT 2011


----------------------------------------------------------------------
Revision: b76ceb5b01114084785a0ad24baca3e425a9fbcf
Parent:   455864fc2a2d3f9a352f3cfa5f21ca6fffac6001
Author:   andrew.victor at mxit.com
Date:     05/03/11 17:22:51
Branch:   im.pidgin.pidgin.next.major
URL: http://d.pidgin.im/viewmtn/revision/info/b76ceb5b01114084785a0ad24baca3e425a9fbcf

Changelog: 

Add API: purple_request_field_set_tooltip & purple_request_field_get_tooltip

This allows protocol prpl's to provide some context-sensitive help text
for Requiest UI fields.


Changes against parent 455864fc2a2d3f9a352f3cfa5f21ca6fffac6001

  patched  ChangeLog.API
  patched  libpurple/request.c
  patched  libpurple/request.h
  patched  pidgin/gtkrequest.c

-------------- next part --------------
============================================================
--- libpurple/request.c	cc2b05b46a40779cd9faa24fbffc8b9bfa2442ff
+++ libpurple/request.c	c3bffd1695fd47406da8b1723c1b7cf196738292
@@ -365,6 +365,7 @@ purple_request_field_destroy(PurpleReque
 	g_free(field->id);
 	g_free(field->label);
 	g_free(field->type_hint);
+	g_free(field->tooltip);
 
 	if (field->type == PURPLE_REQUEST_FIELD_STRING)
 	{
@@ -428,6 +429,15 @@ void
 }
 
 void
+purple_request_field_set_tooltip(PurpleRequestField *field, const char *tooltip)
+{
+	g_return_if_fail(field != NULL);
+
+	g_free(field->tooltip);
+	field->tooltip = g_strdup(tooltip);
+}
+
+void
 purple_request_field_set_required(PurpleRequestField *field, gboolean required)
 {
 	g_return_if_fail(field != NULL);
@@ -502,6 +512,14 @@ purple_request_field_get_type_hint(const
 	return field->type_hint;
 }
 
+const char *
+purple_request_field_get_tooltip(const PurpleRequestField *field)
+{
+	g_return_val_if_fail(field != NULL, NULL);
+
+	return field->tooltip;
+}
+
 gboolean
 purple_request_field_is_required(const PurpleRequestField *field)
 {
============================================================
--- libpurple/request.h	f3460d06e7653696508046113ed3205809fb4add
+++ libpurple/request.h	a23823bdef393da5bbd160e88f8b14ee5c124984
@@ -180,6 +180,7 @@ struct _PurpleRequestField
 	} u;
 
 	void *ui_data;
+	char *tooltip;
 
 };
 #endif
@@ -517,6 +518,18 @@ void purple_request_field_set_type_hint(
 									  const char *type_hint);
 
 /**
+ * Sets the tooltip for the field.
+ *
+ * This is optionally used by the UIs to provide a tooltip for
+ * the field.
+ *
+ * @param field     The field.
+ * @param tooltip   The tooltip text.
+ */
+void purple_request_field_set_tooltip(PurpleRequestField *field,
+									const char *tooltip);
+
+/**
  * Sets whether or not a field is required.
  *
  * @param field    The field.
@@ -582,6 +595,15 @@ const char *purple_request_field_get_typ
 const char *purple_request_field_get_type_hint(const PurpleRequestField *field);
 
 /**
+ * Returns the field's tooltip.
+ *
+ * @param field The field.
+ *
+ * @return The field's tooltip.
+ */
+const char *purple_request_field_get_tooltip(const PurpleRequestField *field);
+
+/**
  * Returns whether or not a field is required.
  *
  * @param field The field.
============================================================
--- pidgin/gtkrequest.c	c13851355e046995c5e133960c40c9e4c2fe48cd
+++ pidgin/gtkrequest.c	14a5189d407b440d89c2320137c1c1b275de7858
@@ -862,6 +862,10 @@ create_string_field(PurpleRequestField *
 			gtk_text_buffer_set_text(buffer, value, -1);
 		}
 
+#if GTK_CHECK_VERSION(2,12,0)
+		gtk_widget_set_tooltip_text(textview, purple_request_field_get_tooltip(field));
+#endif
+
 		gtk_text_view_set_editable(GTK_TEXT_VIEW(textview),
 			purple_request_field_string_is_editable(field));
 
@@ -886,6 +890,10 @@ create_string_field(PurpleRequestField *
 		if (value != NULL)
 			gtk_entry_set_text(GTK_ENTRY(widget), value);
 
+#if GTK_CHECK_VERSION(2,12,0)
+		gtk_widget_set_tooltip_text(widget, purple_request_field_get_tooltip(field));
+#endif
+
 		if (purple_request_field_string_is_masked(field))
 		{
 			gtk_entry_set_visibility(GTK_ENTRY(widget), FALSE);
@@ -926,6 +934,10 @@ create_int_field(PurpleRequestField *fie
 		gtk_entry_set_text(GTK_ENTRY(widget), buf);
 	}
 
+#if GTK_CHECK_VERSION(2,12,0)
+	gtk_widget_set_tooltip_text(widget, purple_request_field_get_tooltip(field));
+#endif
+
 	g_signal_connect(G_OBJECT(widget), "focus-out-event",
 					 G_CALLBACK(field_int_focus_out_cb), field);
 
@@ -940,6 +952,10 @@ create_bool_field(PurpleRequestField *fi
 	widget = gtk_check_button_new_with_label(
 		purple_request_field_get_label(field));
 
+#if GTK_CHECK_VERSION(2,12,0)
+	gtk_widget_set_tooltip_text(widget, purple_request_field_get_tooltip(field));
+#endif
+
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),
 		purple_request_field_bool_get_default_value(field));
 
@@ -970,6 +986,10 @@ create_choice_field(PurpleRequestField *
 		gtk_combo_box_set_active(GTK_COMBO_BOX(widget),
 						purple_request_field_choice_get_default_value(field));
 
+#if GTK_CHECK_VERSION(2,12,0)
+		gtk_widget_set_tooltip_text(widget, purple_request_field_get_tooltip(field));
+#endif
+
 		g_signal_connect(G_OBJECT(widget), "changed",
 						 G_CALLBACK(field_choice_menu_cb), field);
 	}
@@ -987,6 +1007,10 @@ create_choice_field(PurpleRequestField *
 
 		widget = box;
 
+#if GTK_CHECK_VERSION(2,12,0)
+		gtk_widget_set_tooltip_text(widget, purple_request_field_get_tooltip(field));
+#endif
+
 		for (l = labels, i = 0; l != NULL; l = l->next, i++)
 		{
 			const char *text = l->data;
@@ -1034,6 +1058,10 @@ create_image_field(PurpleRequestField *f
 	g_object_unref(G_OBJECT(loader));
 	g_object_unref(G_OBJECT(scale));
 
+#if GTK_CHECK_VERSION(2,12,0)
+	gtk_widget_set_tooltip_text(widget, purple_request_field_get_tooltip(field));
+#endif
+
 	return widget;
 }
 
@@ -1049,6 +1077,10 @@ create_account_field(PurpleRequestField 
 		purple_request_field_account_get_filter(field),
 		field);
 
+#if GTK_CHECK_VERSION(2,12,0)
+	gtk_widget_set_tooltip_text(widget, purple_request_field_get_tooltip(field));
+#endif
+
 	return widget;
 }
 
============================================================
--- ChangeLog.API	a9bc474642a87557b86761c858054ce203dc049f
+++ ChangeLog.API	6b7b66d0ec7a23be56b096e8b033ca14d7347d21
@@ -5,6 +5,8 @@ version 3.0.0 (??/??/????):
 		Added:
 		* purple_notify_searchresult_column_set_visible
 		* purple_notify_searchresult_column_is_visible
+		* purple_request_field_set_tooltip
+		* purple_request_field_get_tooltip
 
 		Removed:
 		* purple_core_migrate


More information about the Commits mailing list