2009-03-12 Claudio Saavedra <csaavedra@igalia.com>
+ Based on a patch by Daniel Borgmann (danielb@openismus.com)
+
+ * src/hildon-entry.c (hildon_entry_refresh_contents),
+ (hildon_entry_get_text), (hildon_entry_init): Do not use the
+ widget name, set the logical color directly instead and a boolean
+ showing_placeholder instead.
+ * src/hildon-text-view.c (hildon_text_view_refresh_contents): Do not
+ use the widget name here either.
+
+ Fixes: NB#105678 (HildonTextView should use logical colours
+ instead of setting widget name)
+
+2009-03-12 Claudio Saavedra <csaavedra@igalia.com>
+
Patch by Daniel Elster (danielk@openismus.com)
* src/hildon-touch-selector.[ch] (HildonTouchSelectorPrintFunc):
*/
#include "hildon-entry.h"
+#include "hildon-helper.h"
G_DEFINE_TYPE (HildonEntry, hildon_entry, GTK_TYPE_ENTRY);
struct _HildonEntryPrivate
{
gchar *placeholder;
+ gboolean showing_placeholder;
};
-static const gchar *placeholder_widget_name = "hildon-entry-placeholder";
-
/* Function used to decide whether to show the placeholder or not */
static void
hildon_entry_refresh_contents (GtkWidget *entry)
{
HildonEntryPrivate *priv = HILDON_ENTRY (entry)->priv;
- gboolean showing_placeholder, entry_has_focus;
+ gboolean entry_has_focus;
- showing_placeholder = g_str_equal (gtk_widget_get_name (entry), placeholder_widget_name);
entry_has_focus = GTK_WIDGET_HAS_FOCUS (entry);
- if (showing_placeholder) {
+ if (priv->showing_placeholder) {
if (entry_has_focus) {
/* Remove the placeholder when the widget obtains focus */
- gtk_widget_set_name (entry, NULL);
+ hildon_helper_set_logical_color (entry, GTK_RC_TEXT, GTK_STATE_NORMAL, "ReversedTextColor");
+ priv->showing_placeholder = FALSE;
gtk_entry_set_text (GTK_ENTRY (entry), "");
} else {
/* Update the placeholder (it may have been changed) */
const gchar *text = gtk_entry_get_text (GTK_ENTRY (entry));
if (text[0] == '\0' && !entry_has_focus) {
if (priv->placeholder[0] != '\0') {
- gtk_widget_set_name (entry, placeholder_widget_name);
+ hildon_helper_set_logical_color (entry, GTK_RC_TEXT, GTK_STATE_NORMAL, "SecondaryTextColor");
+ priv->showing_placeholder = TRUE;
gtk_entry_set_text (GTK_ENTRY (entry), priv->placeholder);
}
}
{
g_return_val_if_fail (HILDON_IS_ENTRY (entry), NULL);
- if (g_str_equal (gtk_widget_get_name (GTK_WIDGET (entry)), placeholder_widget_name)) {
+ if (entry->priv->showing_placeholder) {
return "";
}
{
self->priv = HILDON_ENTRY_GET_PRIVATE (self);
self->priv->placeholder = g_strdup ("");
+ self->priv->showing_placeholder = FALSE;
}
gdouble y; /* tap y position */
};
-static const gchar *placeholder_widget_name = "hildon-text-view-placeholder";
-
/* Function used to decide whether to show the placeholder or not */
static void
hildon_text_view_refresh_contents (GtkWidget *text_view)
if ((bufsize > 0) || GTK_WIDGET_HAS_FOCUS (text_view)) {
/* Display the main buffer if it contains text or the widget is focused */
- gtk_widget_set_name (text_view, NULL);
+ hildon_helper_set_logical_color (text_view, GTK_RC_TEXT, GTK_STATE_NORMAL, "ReversedTextColor");
gtk_text_view_set_buffer (GTK_TEXT_VIEW (text_view), priv->main_buffer);
} else {
/* Otherwise, display the placeholder */
- gtk_widget_set_name (text_view, placeholder_widget_name);
+ hildon_helper_set_logical_color (text_view, GTK_RC_TEXT, GTK_STATE_NORMAL, "SecondaryTextColor");
gtk_text_view_set_buffer (GTK_TEXT_VIEW (text_view), priv->placeholder_buffer);
}
}