Re: How to program a simple dialog?



Florian Harmuth wrote:
Hello all,
i try to program a simple dialog without success.

Here is my actual code:
<code>
#include <unistd.h>
#include <stdlib.h>
#include <gtk/gtk.h>

void quick_message () {

   GtkWidget *system_dialog, *label;

   /* Create the widgets */

   system_dialog = gtk_dialog_new ();
   gtk_widget_set_name (system_dialog, "system_dialog");
   gtk_window_set_title (GTK_WINDOW (system_dialog), "System Settings");
   gtk_window_set_position (GTK_WINDOW (system_dialog), GTK_WIN_POS_CENTER);
   gtk_window_set_modal (GTK_WINDOW (system_dialog), TRUE);
   gtk_window_set_default_size (GTK_WINDOW (system_dialog), 500, 280);
   gtk_window_set_resizable (GTK_WINDOW (system_dialog), FALSE);
   gtk_window_set_type_hint (GTK_WINDOW (system_dialog),
GDK_WINDOW_TYPE_HINT_DIALOG);

   label = gtk_label_new ("");

   /* Ensure that the dialog box is destroyed when the user responds. */

   g_signal_connect_swapped (system_dialog,
                             "response",
                             G_CALLBACK (gtk_widget_destroy),
                             system_dialog);

   /* Add the label, and show everything we've added to the dialog. */

   gtk_container_add (GTK_CONTAINER (GTK_DIALOG(system_dialog)->vbox),
                      label);
   gtk_widget_show_all (system_dialog);
}


int main(int argc, char *argv[])
{
    quick_message();

    return 0;
}
</code>

Here is my compile line: "cc -o tc_system_new main.c `pkg-config --cflags
--libs gtk+-2.0 gthread-2.0 glib-2.0`"

And here is my error output:

[snip]

Any suggestions?

Yes. Read the GTK+ Tutorial at http://gtk.org/tutorial/ . This way you would know that you must call gtk_init() at the start of the program (that's the cause for the messages), and that you need a call to gtk_main() to do anything useful (in this case, displaying the window).


--
I must have slipped a disk -- my pack hurts!

Eduardo M KALINOWSKI
ekalin gmail com
http://move.to/hpkb




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