On Sun, Feb 25, 2007 at 10:15:34PM +0300, ?????? ?????? ??????? wrote: > > How to change brogressbar bar color? I need use progress bar's with > different colors. modify_bg/fg/etc with STATE_NORMAL/STATE_PRELIGHT does > not work. May be, I doing something wrong? Maybe you have a Gtk+ theme installed. You can't defeat a theme engine when it decides to draw things its way. If you really really need to draw them your way, you have to draw them yourself. Drawing progress bars is not hard, look at gtkprogressbar.c source. (You may want to draw all progress bars in your app to keep it visually consistent at least with itself.) Yeti -- Whatever. ======================================================================== /* If this doesn't work all your color are belong to the theme engine. * Resistance is futile. */ #include <gtk/gtk.h> int main(int argc, char *argv[]) { GtkWidget *window, *vbox, *label, *progress; gint s, i; GdkColormap *cmap; GdkColor color; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "Bloody Color Progressbars"); g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL); gtk_window_set_default_size(GTK_WINDOW(window), 480, -1); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), vbox); for (s = 0; s < 2; s++) { label = gtk_label_new(s ? "Both" : "Bar"); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_misc_set_padding(GTK_MISC(label), 4, 4); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); for (i = 0; i < 11; i++) { progress = gtk_progress_bar_new(); gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress), g_random_double_range(0.05, 0.95)); cmap = gtk_widget_get_colormap(progress); color.red = g_random_int_range(0x100, 0x10000); color.green = g_random_int_range(0x100, 0x10000); color.blue = g_random_int_range(0x100, 0x10000); gdk_colormap_alloc_color(cmap, &color, FALSE, TRUE); gtk_widget_modify_bg(progress, GTK_STATE_PRELIGHT, &color); if (s) { color.red /= 2; color.green /= 2; color.blue /= 2; gdk_colormap_alloc_color(cmap, &color, FALSE, TRUE); gtk_widget_modify_bg(progress, GTK_STATE_NORMAL, &color); } gtk_box_pack_start(GTK_BOX(vbox), progress, FALSE, FALSE, 0); } } gtk_widget_show_all(window); gtk_main(); return 0; } _______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list