Re: help with window widgets
- From: ybisou <yanniepa yahoo com>
- To: gtk-list gnome org
- Subject: Re: help with window widgets
- Date: Sun, 12 Nov 2006 21:41:13 -0800 (PST)
> Why do you put gtk_widget_show_all and gtk_main calls in the loop? You
> should move at least the gtk_main call outside of the loop.
I made some changes but I still can't have the widget to output all the
integers coming from the STDIN. Only the first one is on the screen ! I will
appreciate if you could help me, thanks !
Here is a snipet of the code...
// GTK initializations
int main( int argc, char *argv[] )
{
/* GTK widget setup */
unsigned int val;
char buf[5];
while(read(STDIN_FILENO, &val, sizeof(int))) // here is my problem, I'm not
able to actually go through this while loop more than once or is there a way
to refresh the windows so their contents could also be refreshed(variables)?
{
char temp[5];
//read(STDIN_FILENO, &val, sizeof(int));
buf[0]=ita(val/100);
buf[1]=ita((val-((val/100)*100))/10);
buf[2]='.';
buf[3]=ita(val-((val/10)*10));
printf(" reading %d",val); //just making sure i'm reading val
// --------------------------------------------------------------------
// Create text entry widget and modify.
// --------------------------------------------------------------------
text_entry_Widget = gtk_entry_new();
gtk_widget_modify_text(text_entry_Widget, GTK_STATE_NORMAL,
&colorGreen);
gtk_widget_modify_base(text_entry_Widget, GTK_STATE_NORMAL,
&colorBlack);
GtkStyle *style = gtk_widget_get_style(text_entry_Widget);
pango_font_description_set_weight(style->font_desc, PANGO_WEIGHT_BOLD);
gtk_widget_modify_font(text_entry_Widget, style->font_desc);
int text_width = 5; // Width of field in characters
gtk_entry_set_width_chars(GTK_ENTRY(text_entry_Widget), text_width);
gtk_editable_set_editable(GTK_EDITABLE(text_entry_Widget), FALSE);
GTK_WIDGET_UNSET_FLAGS(text_entry_Widget, GTK_CAN_FOCUS);
strcat(buf," V"); // V for volts after the int
gtk_entry_set_text(GTK_ENTRY(text_entry_Widget), buf); // output the int
value
PangoFontDescription *font_desc = pango_font_description_from_string
("PANGO_STYLE_OBLIQUE,Monospace 30");
gtk_widget_modify_font (text_entry_Widget, font_desc);
pango_font_description_free (font_desc);
// --------------------------------------------------------------------
vbox = gtk_vbox_new (FALSE, 5);
gtk_box_pack_start (GTK_BOX (vBox_Widget), vbox, FALSE, FALSE, 0);
frame = gtk_frame_new ("DC Voltages");
label = gtk_label_new ("\nThis voltage comes from 12 V battery \n"\
"It's value should be stable.\n"\
"When undervoltage, a signal is generated");
PangoFontDescription *font_desc2 = pango_font_description_from_string
("PANGO_STYLE_OBLIQUE,Monospace 10");
//PangoFontDescription *font_desc2 = pango_font_description_from_string
("PANGO_STYLE_OBLIQUE,PANGO_VARIANT_NORMAL,PANGO_WEIGHT_BOLD,PANGO_STRETCH_EXPANDED
,Monospace 30");
gtk_widget_modify_font (label, font_desc2);
pango_font_description_free (font_desc2);
gtk_widget_show (label);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), text_entry_Widget, NULL, NULL, 0);
gtk_widget_show (text_entry_Widget); // show the int value
gtk_container_add (GTK_CONTAINER (hbox), vBox_Widget);
text=gtk_text_new(NULL, NULL);
gtk_widget_show(text);
gtk_container_add(GTK_CONTAINER(vbox), text);
gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL, buffer, strlen(buffer));
//Text motif
fnt=gdk_font_load("-unknown-Arial-normal-r-normal-*-*-650-96-96-p-0-iso8859-1");
gtk_text_insert (GTK_TEXT (text), fnt, &text->style->black, NULL,
"\nSupports ", -1);
//creating a seperator
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, TRUE, 5);
gtk_widget_show (separator);
// some other stuff here
}
gtk_widget_show_all (window);
gtk_main ();
close(fd);
return 0;
}
--
View this message in context: http://www.nabble.com/help-with-window-widgets-tf2615494.html#a7311745
Sent from the Gtk+ - General mailing list archive at Nabble.com.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]