Find the answer to your Linux question:
Results 1 to 4 of 4
Can anyone with gtk experience help me? I written several command line based programs but now I want to write graphics for them. Now, the problem is how to set ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux User
    Join Date
    Oct 2004
    Location
    Serbia&Montenegro
    Posts
    281

    Gtk help


    Can anyone with gtk experience help me? I written several command line based programs but now I want to write graphics for them. Now, the problem is how to set the results of the program to be printed in the window?
    Linux registered user #358842
    Human knowledge belongs to the world.

  2. #2
    Linux User
    Join Date
    Jul 2004
    Location
    Poland
    Posts
    368
    How about using pipes (look for popen() function) to read data from your command-line programs and displaying that data in Gtk text widgets?
    "I don't know what I'm running from
    And I don't know where I'm running to
    There's something deep and strange inside of me I see"

  3. #3
    Linux User
    Join Date
    Oct 2004
    Location
    Serbia&Montenegro
    Posts
    281
    Thanks, I'll try that. Here is another question: I'm doing a text editor in gtk it's good so far, I created the graphic look, menu. I programmed it that when I click on open it displays a file selection dialog. My problem is that when I select the file it won't open it in text widget. When I specify the file in the code it opens fine. Here's the function that I use for opening:

    Code:
    FILE *infile;
    infile = fopen(filename, "r");
    
        if (infile) {
          char buffer[1024];
          int nchars;
    
          while (1)
            {
              nchars = fread(buffer, 1, 1024, infile);
              gtk_text_insert (GTK_TEXT (text), fixed_font, NULL,
                               NULL, buffer, nchars);
    
              if &#40;nchars < 1024&#41;
                break;
            &#125;
    
          fclose &#40;infile&#41;;
        &#125;
    I set filename to the selected file in the file selection dialog. Any ideas what's the problem?
    Linux registered user #358842
    Human knowledge belongs to the world.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575
    It could be that fopen fails because filename does not have the correct
    value.I suggest checking the return value of fopen.You should be
    doing that in any case really.Same goes for the return value of fread.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •