Loading ...
Sorry, an error occurred while loading the content.

Warning when selecting text in GEdit.text

Expand Messages
  • Flavio
    Hello all, I receive a warning when I try to use select_region method of a GEdit.text class. For example let w = GWindow.window () in let t = GEdit.text
    Message 1 of 3 , Jun 28, 2003
    • 0 Attachment
      Hello all,
      I receive a warning when I try to use select_region method of a GEdit.text
      class. For example

      let w = GWindow.window () in
      let t = GEdit.text ~packing: w#add () in
      t#insert "some text here\n";
      t#select_region ~start: 1 ~stop: 5;
      w#show ();
      ignore (w#connect#destroy ~callback: GMain.Main.quit);
      GMain.Main.main()

      $ ocaml -I /usr/lib/ocaml/lablgtk/ lablgtk.cma gtkInit.cmo prova.ml

      Gdk-CRITICAL **: file gdkwindow.c: line 1390 (gdk_window_get_size): assertion
      `window != NULL' failed.

      Gdk-CRITICAL **: file gdkwindow.c: line 1390 (gdk_window_get_size): assertion
      `window != NULL' failed.

      but the program starts and seem to behave correctly.

      If i try to execute exactly the same code with t#select_region line commented
      I don't get any error.

      Do you have any hints?

      Thanks in advance
      Flavio
    • Stalkern 2
      ... The error assertion `window != NULL failed is self-explanatory: show the window before launching the selection: let w = GWindow.window () in let t =
      Message 2 of 3 , Jun 28, 2003
      • 0 Attachment
        Il Saturday 28 June 2003 13:00, Flavio ha scritto:
        > let w = GWindow.window () in
        > let t = GEdit.text ~packing: w#add () in
        > t#insert "some text here\n";
        > t#select_region ~start: 1 ~stop: 5;
        > w#show ();
        > ignore (w#connect#destroy ~callback: GMain.Main.quit);
        > GMain.Main.main()


        The error "assertion `window != NULL' failed" is self-explanatory:
        show the window before launching the selection:

        let w = GWindow.window () in
        let t = GEdit.text ~packing: w#add () in
        t#insert "some text here\n";
        w#show ();
        t#select_region ~start: 1 ~stop: 5;
        ignore (w#connect#destroy ~callback: GMain.Main.quit);
        GMain.Main.main()

        In general, show windows ASAP.

        Ciao
        Ernesto
      • Remi Vanicat
        ... firstly, it is not a problem related to ocaml, but a problem related to gtk. The solution here is to realize the windows before selecting something in it :
        Message 3 of 3 , Jun 28, 2003
        • 0 Attachment
          Flavio <sixdegreesoit@...> writes:

          > Hello all,
          > I receive a warning when I try to use select_region method of a GEdit.text
          > class. For example
          >
          > let w = GWindow.window () in
          > let t = GEdit.text ~packing: w#add () in
          > t#insert "some text here\n";
          > t#select_region ~start: 1 ~stop: 5;
          > w#show ();
          > ignore (w#connect#destroy ~callback: GMain.Main.quit);
          > GMain.Main.main()
          >
          > $ ocaml -I /usr/lib/ocaml/lablgtk/ lablgtk.cma gtkInit.cmo prova.ml
          >
          > Gdk-CRITICAL **: file gdkwindow.c: line 1390 (gdk_window_get_size): assertion
          > `window != NULL' failed.
          >
          > Gdk-CRITICAL **: file gdkwindow.c: line 1390 (gdk_window_get_size): assertion
          > `window != NULL' failed.
          >
          > but the program starts and seem to behave correctly.
          >
          > If i try to execute exactly the same code with t#select_region line commented
          > I don't get any error.
          >
          > Do you have any hints?

          firstly, it is not a problem related to ocaml, but a problem related
          to gtk.

          The solution here is to realize the windows before selecting something
          in it :

          let w = GWindow.window () in
          let t = GEdit.text ~packing: w#add () in
          t#misc#realize ();
          t#insert "some text here\n";
          t#select_region ~start: 1 ~stop: 5;
          w#show ();
          ignore (w#connect#destroy ~callback: GMain.Main.quit);
          GMain.Main.main()


          --
          RĂ©mi Vanicat
          vanicat@labri.u-bordeaux.fr
          http://dept-info.labri.u-bordeaux.fr/~vanicat
        Your message has been successfully submitted and would be delivered to recipients shortly.