/* parPort02.c */ /* Compilació : gcc -o parPort02 parPort02.c `pkg-config --cflags --libs libglade-2.0 gtk+-2.0` -rdynamic Execució : ./parPort02 */ /* 20071031 www.binefa.net */ #include #include static GtkWidget *finestraPrincipal; static gboolean gbSel; static guchar gucByte; void vIniciaVariables(){ gbSel = FALSE; gucByte = 0x00; } void vTramet(gboolean gbDirecte){ if(gbDirecte){ /* outb(gucByte,DATA); */ g_print("Escric directament : 0x%X\n",gucByte); }else g_print("No escric directament : 0x%X\n",gucByte); } void on_button1_clicked(GtkWidget *widget){ vTramet(TRUE); } void on_checkbutton1_toggled(GtkWidget *widget){ if(gtk_toggle_button_get_active((GtkToggleButton *)widget)) gbSel = TRUE; else gbSel = FALSE; } void on_togglebutton_b7_toggled(GtkWidget *widget){ if(gtk_toggle_button_get_active((GtkToggleButton *)widget)) gucByte |= 0x80; else gucByte &= 0x7F; vTramet(gbSel); } void on_togglebutton_b6_toggled(GtkWidget *widget){ if(gtk_toggle_button_get_active((GtkToggleButton *)widget)) gucByte |= 0x40; else gucByte &= 0xBF; vTramet(gbSel); } void on_togglebutton_b5_toggled(GtkWidget *widget){ if(gtk_toggle_button_get_active((GtkToggleButton *)widget)) gucByte |= 0x20; else gucByte &= 0xDF; vTramet(gbSel); } void on_togglebutton_b4_toggled(GtkWidget *widget){ if(gtk_toggle_button_get_active((GtkToggleButton *)widget)) gucByte |= 0x10; else gucByte &= 0xEF; vTramet(gbSel); } void on_togglebutton_b3_toggled(GtkWidget *widget){ if(gtk_toggle_button_get_active((GtkToggleButton *)widget)) gucByte |= 0x08; else gucByte &= 0xF7; vTramet(gbSel); } void on_togglebutton_b2_toggled(GtkWidget *widget){ if(gtk_toggle_button_get_active((GtkToggleButton *)widget)) gucByte |= 0x04; else gucByte &= 0xFB; vTramet(gbSel); } void on_togglebutton_b1_toggled(GtkWidget *widget){ if(gtk_toggle_button_get_active((GtkToggleButton *)widget)) gucByte |= 0x02; else gucByte &= 0xFD; vTramet(gbSel); } void on_togglebutton_b0_toggled(GtkWidget *widget){ if(gtk_toggle_button_get_active((GtkToggleButton *)widget)) gucByte |= 0x01; else gucByte &= 0xFE; vTramet(gbSel); } int main(int argc, char *argv[]){ GladeXML *arbreDeGinys; gtk_init(&argc,&argv); vIniciaVariables(); arbreDeGinys = glade_xml_new("parPort01.glade",NULL,NULL); finestraPrincipal = glade_xml_get_widget(arbreDeGinys,"window1"); glade_xml_signal_autoconnect(arbreDeGinys); gtk_widget_show_all(finestraPrincipal); gtk_main(); return 0; }