GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sat Aug 30, 2014 12:12 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: colos of progressbar
PostPosted: Fri Oct 14, 2005 4:52 pm 
Offline

Joined: Fri Oct 14, 2005 4:42 pm
Posts: 1
Hello,
i'am making an application for showing data received from a sensor.
Is a simple gui composed (for now) from many progressbar.
I have tried to change color of statusbar for obtaining somewat like this
Image
but with the code below i obtain this
Image.
wath is my error?
Thanks for replies :)

Code:
#include <gtk/gtk.h>

GtkWidget *window;
GtkWidget *vbox1,*vbox2,*hbox1,*hbox2,*hbox3;
GtkWidget *pbar_rxacc,*pbar_pxacc,*pbar_rtemp,*pbar_ptemp;
GtkWidget *sep1,*sep2;

static gboolean delete_event( GtkWidget *widget, GdkEvent *event, gpointer data )
{
    gtk_main_quit ();
    return FALSE;
}
int main( int   argc, char *argv[] )
{
   gtk_init (&argc, &argv);
   
    /*colors & styles for progressbars*/
   GdkColor red;
   red.red=65535;
   red.green=0;
   red.blue=0;
   
    GdkColor green;
    green.green=65535;
    green.red=green.blue=0;
   
    GdkColor blue;
    blue.blue=65535;
    blue.red=blue.green=0;
   
    GtkRcStyle *red_st, *blue_st,*green_st;
    red_st=gtk_rc_style_new();
    blue_st=gtk_rc_style_new();
    green_st=gtk_rc_style_new();
    int i;
    for(i=0;i<5;i++)
    {
       /*tryng differents alternatives*/
       red_st->color_flags[i]=GTK_RC_FG; 
       red_st->fg[i]=red;
       blue_st->color_flags[i]=GTK_RC_BG;
       blue_st->bg[i]=blue;
       green_st->color_flags[i]=GTK_RC_BASE;
       green_st->base[i]=green;
    }
   
    /*init all widgets*/
    /*box*/
    vbox1=gtk_vbox_new(FALSE,0);
    vbox2=gtk_vbox_new(FALSE,0);
    hbox1=gtk_hbox_new(FALSE,0);
    hbox2=gtk_hbox_new(FALSE,0);
    hbox3=gtk_hbox_new(FALSE,0);
   
    /*progress bar*/
    pbar_rxacc=gtk_progress_bar_new();
       gtk_progress_bar_set_fraction ((GtkProgressBar*)pbar_rxacc,0.5);
       gtk_progress_bar_set_text((GtkProgressBar*)pbar_rxacc,"Roll x acceleration");
      gtk_widget_modify_style(pbar_rxacc,blue_st);
      
    pbar_rtemp=gtk_progress_bar_new();
        gtk_progress_bar_set_orientation((GtkProgressBar*)pbar_rtemp,GTK_PROGRESS_BOTTOM_TO_TOP);
       gtk_progress_bar_set_text((GtkProgressBar*)pbar_rtemp,"Roll\nsensor\ntemperature");
      gtk_widget_modify_style(pbar_rtemp,red_st);
      
    pbar_pxacc=gtk_progress_bar_new();
       gtk_progress_bar_set_fraction ((GtkProgressBar*)pbar_pxacc,0.5);
       gtk_progress_bar_set_text((GtkProgressBar*)pbar_pxacc,"Pitch x acceleration");
      gtk_widget_modify_style(pbar_pxacc,green_st);
      
    pbar_ptemp=gtk_progress_bar_new();
       gtk_progress_bar_set_orientation((GtkProgressBar*)pbar_ptemp,GTK_PROGRESS_BOTTOM_TO_TOP);
       gtk_progress_bar_set_text((GtkProgressBar*)pbar_ptemp,"Pitch\nsensor\ntemperature");
       gtk_widget_modify_style(pbar_ptemp,red_st);
      
   /*separators*/
   sep1= gtk_hseparator_new ();
   sep2= gtk_vseparator_new ();
   
    /*packing widgets in the boxes*/
    gtk_box_pack_start((GtkBox*)vbox1,hbox1,TRUE,TRUE,5);
    gtk_box_pack_start((GtkBox*)vbox1,sep1,FALSE,TRUE,5);
    gtk_box_pack_start((GtkBox*)vbox1,hbox2,TRUE,TRUE,5);
    gtk_box_pack_start((GtkBox*)hbox2,vbox2,TRUE,TRUE,5);
    gtk_box_pack_start((GtkBox*)vbox2,pbar_rxacc,FALSE,TRUE,5);
   gtk_box_pack_start((GtkBox*)vbox2,pbar_pxacc,FALSE,TRUE,5);
   gtk_box_pack_start((GtkBox*)hbox2,sep2,FALSE,TRUE,5);
   gtk_box_pack_start((GtkBox*)hbox2,hbox3,FALSE,TRUE,5);
   gtk_box_pack_end((GtkBox*)hbox3,pbar_rtemp,FALSE,TRUE,5);
   gtk_box_pack_end((GtkBox*)hbox3,pbar_ptemp,FALSE,TRUE,5);
   
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    g_signal_connect (G_OBJECT (window), "delete_event",G_CALLBACK (delete_event), NULL);
    gtk_container_add (GTK_CONTAINER (window), vbox1);
    gtk_widget_show_all(window);
   
    gtk_main ();
   
    return 0;
}

_________________
sorry for my english :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group