/pidgin/main: 9abf92629647: Implement a GTK3 version of the plac...
Elliott Sales de Andrade
qulogic at pidgin.im
Sun Jan 27 05:57:51 EST 2013
Changeset: 9abf9262964733e0aadc0dfbcb7726b30f4b33c8
Author: Elliott Sales de Andrade <qulogic at pidgin.im>
Date: 2013-01-27 05:51 -0500
Branch: default
URL: http://hg.pidgin.im/pidgin/main/rev/9abf92629647
Description:
Implement a GTK3 version of the placeholder text.
It might be a bit buggy, but I don't care too much, since 3.2 introduces
a builtin method for it.
Refs #14245.
diffstat:
pidgin/gtkaccount.c | 46 ++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 44 insertions(+), 2 deletions(-)
diffs (109 lines):
diff --git a/pidgin/gtkaccount.c b/pidgin/gtkaccount.c
--- a/pidgin/gtkaccount.c
+++ b/pidgin/gtkaccount.c
@@ -119,7 +119,11 @@ typedef struct
GtkWidget *protocol_menu;
GtkWidget *password_box;
GtkWidget *username_entry;
+#if GTK_CHECK_VERSION(3,0,0)
+ GdkRGBA username_entry_hint_color;
+#else
GdkColor *username_entry_hint_color;
+#endif
GtkWidget *password_entry;
GtkWidget *alias_entry;
GtkWidget *remember_pass_check;
@@ -283,7 +287,11 @@ username_focus_cb(GtkWidget *widget, Gdk
if(!strcmp(gtk_entry_get_text(GTK_ENTRY(widget)), label)) {
gtk_entry_set_text(GTK_ENTRY(widget), "");
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_override_color(widget, GTK_STATE_NORMAL, NULL);
+#else
gtk_widget_modify_text(widget, GTK_STATE_NORMAL,NULL);
+#endif
}
g_hash_table_destroy(table);
@@ -336,7 +344,11 @@ username_nofocus_cb(GtkWidget *widget, G
gtk_entry_set_text(GTK_ENTRY(widget), label);
/* Make sure we can hit it again */
g_signal_handlers_unblock_by_func(widget, G_CALLBACK(username_changed_cb), dialog);
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_override_color(widget, GTK_STATE_NORMAL, &dialog->username_entry_hint_color);
+#else
gtk_widget_modify_text(widget, GTK_STATE_NORMAL, dialog->username_entry_hint_color);
+#endif
}
g_hash_table_destroy(table);
@@ -382,8 +394,13 @@ username_themechange_cb(GObject *widget,
GHashTable *table;
const char *label, *text;
char *temp_text = NULL;
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkStyleContext *context;
+ GtkBorder border;
+#else
GtkStyle *style;
const GtkBorder *border = NULL;
+#endif
gint xsize;
table = dialog->prpl_info->get_account_text_table(NULL);
@@ -393,28 +410,53 @@ username_themechange_cb(GObject *widget,
g_signal_handlers_block_by_func(widget, G_CALLBACK(username_themechange_cb), dialog);
g_signal_handlers_block_by_func(widget, G_CALLBACK(username_changed_cb), dialog);
if (strcmp(text, label)) {
- temp_text = g_strdup (text);
+ temp_text = g_strdup(text);
gtk_entry_set_text(GTK_ENTRY(widget), label);
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_override_color(GTK_WIDGET(widget), GTK_STATE_NORMAL, NULL);
+#else
gtk_widget_modify_text(GTK_WIDGET(widget), GTK_STATE_NORMAL, NULL);
+#endif
}
+#if GTK_CHECK_VERSION(3,0,0)
+ context = gtk_widget_get_style_context(dialog->username_entry);
+ gtk_style_context_get_color(context, GTK_STATE_FLAG_INSENSITIVE,
+ &dialog->username_entry_hint_color);
+#else
style = gtk_rc_get_style(dialog->username_entry);
dialog->username_entry_hint_color = &(style->fg[GTK_STATE_INSENSITIVE]);
+#endif
pango_layout_get_pixel_size(gtk_entry_get_layout(GTK_ENTRY(widget)), &xsize, NULL);
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_style_context_get_margin(context, GTK_STATE_FLAG_NORMAL, &border);
+ xsize += border.left + border.right;
+ gtk_style_context_get_padding(context, GTK_STATE_FLAG_NORMAL, &border);
+ xsize += border.left + border.right;
+#else
xsize += 2 * style->xthickness;
- gtk_style_get (style, GTK_TYPE_ENTRY, "inner-border", &border, NULL);
+ gtk_style_get(style, GTK_TYPE_ENTRY, "inner-border", &border, NULL);
if (border)
xsize += border->left + border->right;
else
xsize += 4; /* 2 * default inner-border */
+#endif
gtk_widget_set_size_request(GTK_WIDGET(widget), xsize, -1);
if (temp_text) {
gtk_entry_set_text(GTK_ENTRY(widget), temp_text);
g_free(temp_text);
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_override_color(GTK_WIDGET(widget), GTK_STATE_NORMAL, NULL);
+#else
gtk_widget_modify_text(GTK_WIDGET(widget), GTK_STATE_NORMAL, NULL);
+#endif
} else
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_override_color(GTK_WIDGET(widget), GTK_STATE_NORMAL, &dialog->username_entry_hint_color);
+#else
gtk_widget_modify_text(GTK_WIDGET(widget), GTK_STATE_NORMAL, dialog->username_entry_hint_color);
+#endif
g_signal_handlers_unblock_by_func(widget, G_CALLBACK(username_themechange_cb), dialog);
g_signal_handlers_unblock_by_func(widget, G_CALLBACK(username_changed_cb), dialog);
More information about the Commits
mailing list