xfdesktop icon text color

Nikolas Arend Nikolas.Arend at gmx.net
Sat May 20 22:52:12 CEST 2006


Brian J. Tarricone wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Nikolas Arend wrote:
>   
>> Brian J. Tarricone wrote:
>>     
>>> -----BEGIN PGP SIGNED MESSAGE-----
>>> Hash: SHA1
>>>
>>> Nikolas Arend wrote:
>>>   
>>>       
>>>> Hi,
>>>>
>>>> I'm playing around a bit with xfdesktop and implemented code for two 
>>>> options that allow for altering the icon label opacity/translucency 
>>>> (alpha value) and the color of the icon text via the mcs plugin.
>>>> Changing the alpha value of the label background works fine but I'm 
>>>> struggling with the icon text color. So far I only managed to modify the 
>>>> text color of the whole parent window, which means the text color in 
>>>> right-click menus etc will change as well.
>>>> How can I access and apply only the color attributes of the icon label 
>>>> text? Is there a member in _XfdesktopIconViewPrivate, *playout maybe? I 
>>>> tried to change Pango attributes for the PangoLayout, with no success.
>>>>
>>>> Does anybody have a hint here (I suppose Brian knows xfdesktop's code 
>>>> inside out)?
>>>>     
>>>>         
>>> Both of these features are already implemented[1], via gtk's theme
>>> system.  I'm not interested in putting options in the MCS plugin.
>>>
>>>   
>>>       
>> Yes, I thought you wouldn't. But now that I've started, I'd like to 
>> finish it, whether or not these options will be implemented. If you 
>> could give me a hint, I'd appreciate it nonetheless. I could use a 
>> patched version myself and/or provide a patch for stable releases, in 
>> case people are interested (which IMO is not too unlikely). Besides, it 
>> was a good exercise with gtk and xfce code.
>>
>> Thanks again for any help,
>>     
>
> Well, it really depends on *how* you're implementing it.  It's hard to
> help in the dark ^_^.
>
>   

Yes, right. For choosing the icon text color, I put a 
gtk_color_button_new_with_color(&color) in the mcs dialog:

    hbox = gtk_hbox_new(FALSE, BORDER);
    gtk_widget_show(hbox);
    gtk_container_add(GTK_CONTAINER(bd->vbox_icon_settings), hbox);
   
    lbl = gtk_label_new_with_mnemonic(_("Icon text _color:"));  
    gtk_misc_set_alignment(GTK_MISC(lbl), 0.0, 0.5);
    gtk_size_group_add_widget(sg, lbl);
    gtk_widget_show(lbl);
    gtk_box_pack_start(GTK_BOX(hbox), lbl, FALSE, FALSE, 0);

    color.red = desktop_icons_text_color.red;
    color.green = desktop_icons_text_color.green;
    color.blue = desktop_icons_text_color.blue;
    bd->text_color_box = cbtn = gtk_color_button_new_with_color(&color);
    gtk_color_button_set_color(GTK_COLOR_BUTTON(cbtn), &color);
    g_object_set_data(G_OBJECT(cbtn), "xfce-cbtnnum",
                      GUINT_TO_POINTER(OPT_ICONSTEXTCOLOR));
    gtk_widget_show(cbtn);
    gtk_box_pack_start(GTK_BOX(hbox), cbtn, FALSE, FALSE, 0);
    g_signal_connect(cbtn, "color-set", G_CALLBACK(set_color_option), bd);
   
    gtk_label_set_mnemonic_widget(GTK_LABEL(lbl), cbtn);

This color is stored as an mcs-setting in desktop.xml (just like 
color1/2 for the desktop background). It's read at startup by 
behavior_settings_load() and applied by 
xfce_desktop_settings_load_initial() which calls the function 
xfce_desktop_set_icon_text_color(desktop, &color). The subsequently 
called functions work in principle just like 
xfdesktop_icon_view_set_font_size()/xfdesktop_icon_view_modify_font_size() 
in xfdesktop-icon-view.c. Well, they're supposed to, that is.
In my function xfdesktop_icon_view_modify_font_color(icon_view, 
text_color) I'd like to make the appropriate changes to the icon text 
color which then get applied by 
gtk_widget_queue_draw(GTK_WIDGET(icon_view)). But I'm not sure what 
exactly in the _XfdesktopIconViewPrivate structure I have to modify to 
alter the icon text color. I tried

gdk_gc_set_rgb_fg_color(*icon_view->priv->parent_window->style->text_gc, 
text_color),

but that, as I said, changes the text color for the entire parent window 
of course (which looks funny).
I basically tried to stick to the way your code is organized for desktop 
"Behavior" settings, the function and variable structure is actually the 
same.

I could make the code available on my web site, if needed. I didn't 
create any patches yet.

Does this help?

Best, Nick.






More information about the Xfce4-dev mailing list