Re: About Check Menu Item




The problem has been resovled, thanks

From: "Nix N. Nix" <nix go-nix ca>
To: jacky618 jacky618 <hhd618 hotmail com>
Subject: Re: About Check Menu Item
Date: Wed, 11 Aug 2004 07:53:52 -0400

On Wed, 2004-08-11 at 04:31, jacky618 jacky618 wrote:
> Hi,
>
> I have a trouble with me when using Gtk+ . In my program, a check menu
was
> used as following:
>
> void on_menuitem_1_toggled(GtkCheckMenuItem        *ckMnItem,
>                                         gpointer         user_data)
> {
>     printf("***");
>
>     if (GTK_CHECK_MENU_ITEM(ckMnItem)->active == TRUE)
>         printf("###");
>     else
>         printf("@@@@");

  if (you_want_weird_looking_printfs)
    fflush (stdout) ;
  else
    printf ("\n") ;
> }
>
>
>   menu1 = gtk_menu_new();
>
>   menuitem_1 = gtk_check_menu_item_new_with_label("Linkage status"));
>   gtk_signal_connect (GTK_OBJECT( menuitem_1), "toggled",
>                     (GtkSignalFunc) on_menuitem_1_toggled,
>                     menuitem_1);
>
>   gtk_menu_append(GTK_MENU(menu1),menuitem_1);
>   gtk_widget_show(menuitem_1);
>
> I hope when the check menu item was selected, it will print  "***###"
> immediately,and "***@@@" when unselected. However, it can not print
> immediately after the menu item was clicked.And until the main window
was
> closed, the strings will appear.

The strings do not appear because the streams stdout and stderr are line
buffered.  That is, when you issue a printf, the text does not show up
until "\n" is part of one of the printfs.

Alternatively, after you're done all your printfs, call fflush(stdout).
This overrides the line buffering, and guarantees that everything in
stdout is actually on the screen.


_________________________________________________________________
免费下载 MSN Explorer: http://explorer.msn.com/lccn/



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