Re: Gtk+ progress bar color



Works for me too. Thank you!


On 08-03-2017 15:02, Stefan Salewski wrote:
On Wed, 2017-03-08 at 15:52 +0100, Stefan Salewski wrote:
On Wed, 2017-03-08 at 14:18 +0000, Rúben Rodrigues wrote:
I asked to the Google before, but he don't give me nothing about
this
:-). PRELIGHT doesn't work too..
  
Well, the fix suggested by Owen Taylor in that old thread solved it for
me:

#include <gtk/gtk.h>

gint main(gint argc,gchar *argv[])
{
   GtkWidget *window;
   GtkWidget* bar;
   GdkColor color;
   GtkStyle *style;

   gtk_init (&argc,&argv);
   window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
   bar=gtk_progress_bar_new();
   gdk_color_parse("red",&color);
   gtk_widget_modify_bg(bar,GTK_STATE_NORMAL, &color);
   gtk_widget_modify_bg(bar,GTK_STATE_PRELIGHT, &color);
   gtk_widget_modify_bg(bar,GTK_STATE_ACTIVE, &color);
   gtk_widget_modify_bg(bar,GTK_STATE_SELECTED, &color);
   gtk_widget_modify_bg(bar,GTK_STATE_INSENSITIVE, &color);

   gtk_widget_modify_fg(bar,GTK_STATE_NORMAL, &color);
   gtk_widget_modify_fg(bar,GTK_STATE_PRELIGHT, &color);
   gtk_widget_modify_fg(bar,GTK_STATE_ACTIVE, &color);
   gtk_widget_modify_fg(bar,GTK_STATE_SELECTED, &color);
   gtk_widget_modify_fg(bar,GTK_STATE_INSENSITIVE, &color);

   style = gtk_style_new ();
   gdk_color_parse ("red", &style->bg[GTK_STATE_PRELIGHT]);
   gtk_widget_set_style (bar, style);
   g_object_unref (style);

   gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(bar),0.5);
   gtk_container_add(GTK_CONTAINER(window),bar);
   gtk_widget_show_all (window);
   gtk_main();
   return 0;
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]