Changing gtkrc prelight color of a GtkLabel inside of a GtkEventBox
- From: Craig Harding <craigwharding gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Changing gtkrc prelight color of a GtkLabel inside of a GtkEventBox
- Date: Sun, 24 Oct 2010 22:50:04 -0400
I'm trying to find why I can't change the prelight foreground color of a
GtkLabel which is inside a GtkEventBox.
I'd first like to point out that the fg[NORMAL] and font_name fields work
correctly for this gtklabel. It is only the hover over event where I'm
having trouble setting the color (or PRELIGHT) of the label. The GtkLabel in
question in dn_label in setup_display_name.
Thanks for any pointers!
===============
My gtkrc-2.0:
style "display_name_label_style" {
fg[NORMAL] = { 0.0, 0.0, 0.0 }
fg[PRELIGHT] = { 0.0, 0.0, 1.0 }
font_name = "Bold"
}
widget "*personalbar_displayname_label" style "display_name_label_style"
My code:
#define GTKRC_DN_LABEL "personalbar_displayname_label"
void
setup_display_name(GtkWidget *hbox, GtkWidget *dn_box) {
GtkWidget *eb, *dn_label;
const char *display_name, *markup;
dn_label = gtk_label_new(NULL);
/* Give ability to change display name label colors in gtkrc */
gtk_widget_set_name(dn_label, GTKRC_DN_LABEL);
eb = gtk_event_box_new();
gtk_widget_show(GTK_WIDGET(eb));
gtk_container_add(GTK_CONTAINER(eb), GTK_WIDGET(dn_label));
gtk_event_box_set_above_child(GTK_EVENT_BOX(eb), FALSE);
gtk_widget_set_events(GTK_WIDGET(eb), GDK_BUTTON_PRESS_MASK);
/* Make the eventbox transparent so themed colors work ok */
gtk_event_box_set_visible_window(GTK_EVENT_BOX(eb), FALSE);
gtk_container_set_border_width(GTK_CONTAINER(eb), 0);
/* Find the display name, set it, and pack it in */
display_name = purple_prefs_get_string(pref_display_name);
if (!strcmp(display_name, "")) {
purple_debug_info(PLUGIN_ID, "insert_personal_bar: stored display name is
empty, using <Display Name> for label\n");
display_name = "<Display Name>";
}
gtk_label_set_text(dn_label, display_name);
gtk_widget_show (GTK_WIDGET(dn_label));
gtk_box_pack_start (GTK_BOX (dn_box), GTK_WIDGET(eb), FALSE, FALSE, 0);
g_object_set_data(G_OBJECT(hbox), PLUGIN_ID_DN_WIDGET, dn_label);
/* Signals */
g_signal_connect(G_OBJECT(eb), "button-press-event",
G_CALLBACK(on_display_name_focus_cb), NULL);
g_signal_connect(G_OBJECT(eb), "enter-notify-event",
G_CALLBACK(on_display_name_hover_cb), NULL);
g_signal_connect(G_OBJECT(eb), "leave-notify-event",
G_CALLBACK(on_display_name_hover_cb), NULL);
GTK_WIDGET_SET_FLAGS (dn_label, GTK_CAN_FOCUS);
}
/* When hovering over the display name change the
highlighting and the pointer to a 'hand' pointer */
gboolean
on_display_name_hover_cb (GtkWidget *widget, GdkEventFocus *event, gpointer
user_data) {
PidginBuddyList *gtkblist = PIDGIN_BLIST(purple_get_blist());
/* When hovering, change markup and pointer type */
if (event->type == GDK_ENTER_NOTIFY) {
pidgin_set_cursor(gtkblist->window, GDK_HAND2);
}
/* When leaving, change it back to normal */
else if (event->type == GDK_LEAVE_NOTIFY) {
pidgin_set_cursor(gtkblist->window, GDK_ARROW);
}
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]