I have to admit that currently I don't have a clue how to do that in C. I also have no idea how to let the user select a gradient and it's start and end points. But, that can come a little later. I have some more basic things to take care of:
I want to be able to show the current color selected for a given option in my program as a button on the screen with the current selected color as the background color for the button widget. I believe I'm having problems in 2 areas:
- the gtk_color_parse as I'm not sure it's actually doing anything
- the gtk_widget_override_background_color since I never see the color in the button
Here is a snip of definition that might be helpful:
Code:
char css_panel_color[256] = "#ff1364";
Here is the code snippet I don' think is working right:
Code:
panel_win1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW(panel_win1), "GNOME SHELL CSS FILE EDITOR - PANEL OPTIONS");
gtk_window_set_default_size(GTK_WINDOW(panel_win1), 640, 480);
gtk_window_set_position (GTK_WINDOW(panel_win1), GTK_WIN_POS_CENTER);
g_signal_connect (G_OBJECT (panel_win1), "delete_event",
G_CALLBACK (close_window), GTK_CONTAINER(panel_win1));
g_signal_connect (G_OBJECT (panel_win1), "destroy",
G_CALLBACK (close_window), GTK_CONTAINER(panel_win1));
gtk_container_set_border_width (GTK_CONTAINER(panel_win1), 5);
wrkbox1 = gtk_vbox_new(FALSE, 5);
gtk_container_add (GTK_CONTAINER (panel_win1), wrkbox1);
table1 = gtk_table_new(15,10,TRUE);
label1 = gtk_label_new("Panel Color:");
label2 = gtk_label_new("Background:");
gdk_color_parse (css_panel_color, &colorButton); ******** <---- I don't think this is doing anything ********
button_Widget = gtk_button_new_with_label("Current Color");
gtk_widget_override_background_color (button_Widget, GTK_STATE_NORMAL, &colorButton);******** <---- I don't think this is doing anything ********
panel_background_image_active = gtk_radio_button_new(NULL);
gtk_radio_button_set_group(panel_background_image_active,group1);
panel_background_color_active = gtk_radio_button_new(group1);
gtk_toggle_button_set_active (GTK_RADIO_BUTTON (panel_background_color_active), TRUE);
label3 = gtk_label_new("Image:");
label4 = gtk_label_new("Color:");
gtk_table_attach (GTK_TABLE(table1), label1, 0,1,0,1,
GTK_EXPAND, GTK_SHRINK, 0, 0);
gtk_table_attach (GTK_TABLE(table1), button_Widget, 1,3,0,1,
GTK_EXPAND, GTK_SHRINK, 0, 0);
gtk_table_attach (GTK_TABLE(table1), label2, 0,1,1,2,
GTK_EXPAND, GTK_SHRINK, 0, 0);
gtk_table_attach (GTK_TABLE(table1),
panel_background_image_active,
1,2,1,2,
GTK_EXPAND,
GTK_SHRINK,
0, 0);
gtk_table_attach (GTK_TABLE(table1),
panel_background_color_active,
1,2,2,3,
GTK_EXPAND,
GTK_SHRINK,
0, 0);
gtk_table_attach (GTK_TABLE(table1), label3, 2,3,1,2,
GTK_EXPAND, GTK_SHRINK, 0, 0);
gtk_table_attach (GTK_TABLE(table1), label4, 2,3,2,3,
GTK_EXPAND, GTK_SHRINK, 0, 0);
gtk_table_set_row_spacings (GTK_TABLE(table1),3);
gtk_table_set_col_spacings (GTK_TABLE(table1),3);
gtk_container_add(GTK_CONTAINER(wrkbox1), table1);
gtk_widget_show(table1);
It is generating the screen I want, but the "Current Color" box doesn't actually have the background color from the definition.
Any help is always greatly appreciated! I'm making what are big strides to me - most of the gut pieces are there and working, it just a matter of interfacing to them.
Dave ;)