RE: Problems mapping a specific instance of a widget to a styledescribed in an rc file
- From: "Boncek, John" <jboncek hunter com>
- To: "Bill Sousan" <BillS techsi com>, <gtk-app-devel-list gnome org>
- Cc:
- Subject: RE: Problems mapping a specific instance of a widget to a styledescribed in an rc file
- Date: Thu, 13 Oct 2005 11:24:57 -0500
You didn't actually say what isn't working, but I'm guessing
Custom-Button-Style isn't being used. You wrote
widget "Custom-Button" style "Custom-Button-Style"
You need to put an asterisk and dot before the name, like this:
widget "*.Custom-Button" style "Custom-Button-Style"
-----Original Message-----
From: gtk-app-devel-list-bounces gnome org
[mailto:gtk-app-devel-list-bounces gnome org] On Behalf Of Bill Sousan
Sent: Thursday, October 13, 2005 9:11 AM
To: gtk-app-devel-list gnome org
Subject: Problems mapping a specific instance of a widget to a
styledescribed in an rc file
My problem is that I would like to map a specific instance of a widget to
a
style described within an rc file. I have read the docs on widget style
and
naming and am still a little confused. What I need to do is create custom
buttons within my app based on specific styles described in the gtkrc
file.
I am able to describe a default value using the > class "GtkButton" which
works. However, I would like to be able to assign any button I create to
any
style listed within the rc file.
Here is the listing from my code and sample rc file:
#include <gtk/gtk.h>
int
main(int argc, char* argv[])
{
GtkWidget* window;
GtkWidget* buttons[2];
GtkWidget* table;
int i;
gtk_init(&argc, &argv);
gtk_rc_parse( "gtkrc" );
table = gtk_table_new(2, 1, FALSE);
for(i = 0; i < 2; i++)
{
buttons[i] = gtk_button_new_with_label("Button1");
gtk_table_attach_defaults (GTK_TABLE(table), buttons[i], i, i+1,
0,1);
}
/* Set the widget's name here */
gtk_widget_set_name(buttons[1], "Custom-Button");
printf("Widget Name is: %s\n", gtk_widget_get_name(buttons[1]) );
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_add(GTK_CONTAINER(window), table);
gtk_container_set_border_width(GTK_CONTAINER(window), 160);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
// rc file:
style "Default-Button-Style"
{
fg[PRELIGHT] = { 0, 1.0, 1.0 }
bg[PRELIGHT] = { 0, 0, 1.0 }
bg[ACTIVE] = { 1.0, 0, 0 }
fg[ACTIVE] = { 0, 1.0, 0 }
bg[NORMAL] = { 1.0, 1.0, 0 }
fg[NORMAL] = { .99, 0, .99 }
bg[INSENSITIVE] = { 1.0, 1.0, 1.0 }
fg[INSENSITIVE] = { 1.0, 0, 1.0 }
}
style "Custom-Button-Style"
{
fg[PRELIGHT] = { 0.5, 0.5, 0.5 }
bg[PRELIGHT] = { 0.2, .2, .2 }
bg[ACTIVE] = { 1, 1, 1 }
fg[ACTIVE] = { 1, 1, 1 }
bg[NORMAL] = { 0, 0, 0 }
fg[NORMAL] = { .5, .5, .5 }
bg[INSENSITIVE] = { .2, .2, .2 }
fg[INSENSITIVE] = { 1.0, 1.0, 1.0 }
}
class "GtkButton" style "Default-Button-Style"
widget "Custom-Button" style "Custom-Button-Style"
Thanks,
Bill Sousan
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]