GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Fri Aug 26, 2016 1:40 pm

All times are UTC

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: The best of both worlds; CUI and GUI
PostPosted: Sun Feb 17, 2008 1:12 am 
Familiar Face

Joined: Mon Aug 27, 2007 10:43 pm
Posts: 14
Ok I have a question about GTK and how it handles GUI and CUI. Basically I started using Visual C++ and thought that it was causing the problem (and i'm sure I had everything set right, I even tried xaos5's vsprops files too). Turns out that wasn't the problem, I ran into the same thing with GCC command line and Dev-CPP.

The problem is how do you output to the console while not having the command prompt open with a window. I want no console window open with my window, but I want the program to be able to output to the console if it was called from there. I have the following;

#include <gtk/gtk.h>
#include <glib.h>

int main ( int argc, char* argv[] ) {
  GtkWidget *dialog = NULL;
  g_print("Hello Console!");

  gtk_init (&argc, &argv);
  dialog = gtk_message_dialog_new (GTK_WINDOW(NULL),
                                   "Hello Window!");
  gtk_dialog_run (GTK_DIALOG (dialog));
  g_signal_connect_swapped (dialog, "response",
                            G_CALLBACK (gtk_widget_destroy),
  gtk_widget_destroy (dialog);

  return 0;

(I tried replacing g_print with printf from stdio.h, but no luck either)

if I compile without -mwindows it opens a command prompt window and outputs "Hello Console!" then "Hello Window!" in a messagebox as expected, but if opened with double click (i.e. not from the command prompt) it will open a command prompt with it. Now if I do it with -mwindows it will eliminate the command prompt, but douse my ability to output to stdout via g_print or any other method.

It is very import that I have GUI and CUI, as most linux programs do, I believe that power lies in mostly CUI with mapping to the CUI using GUI. I have a full featured set of command line options with GOption and am not willing to choose either GUI or CUI or have a command prompt open with the GUI if not opened from the command line.

I also would not like to have to use hacks to close the CUI on load. I know this has to be a common problem, like in -mwindows the STDOUT get's re-routed or something.

Any help will be very much appriciated,
--Alex (

 Post subject:
PostPosted: Sun Feb 17, 2008 1:54 am 
Familiar Face

Joined: Mon Aug 27, 2007 10:43 pm
Posts: 14
Man this sucks I've studied some of the gimp and test programs with the GTK environment and it seems the best way they've figured out is to make a console and GUI one separately, and newbie windows users will just use myprog.exe and people who like CUI will use myprog-console.exe. This flusters me greatly as in Linux you see things like **ERROR** when closing apps opened from the command line, but if you just double click em you never see the messages.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC

Who is online

Users browsing this forum: Google Adsense [Bot] and 4 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group