Gtk--: Dialog troubles: part 2 (with source)



Hi Guys,

 a while ago I posted a question here regarding the drawing/opening of
multiple
dialogs, which for some odd reason I can not get to work correctly. I got 2
suggestions
(thanks guys) but unfortunateley not what I was looking for. I figured, I'd
give it a second
time and thrown in some source this time:

Anyhow, attached is a program which will attempt to open 2 dialogs (right
now they are
created on top of each other (I didn't feel like tinkering any more with
this)), the first of
which is opened/drawn just fine while the second one comes up blank and
returns a
GTK warning.

If anybody could point out to me what I'm doing wrong, I'd be most greatful
...

Thanks
--> Robert

------------------------------------- cut here
---------------------------------------------
/* test to see if we can display 2 dialogs - RNG */
#include <string.h>
#include <gtk--.h>
#include <gtk/gtk.h>

class GuiDialogOAC : public Gtk_Dialog
     {
     public:
                         GuiDialogOAC (char *title=NULL, char
*message=NULL);
                         ~GuiDialogOAC ();
          virtual void        buildDialogWindow ();

     protected:
          virtual void        fillVBox ();
          virtual void        fillActionArea ();
          virtual void        buttonCallbackOK ();
          virtual void        buttonCallbackApply ();
          virtual void        buttonCallbackCancel ();
          virtual gint        delete_event_impl (GdkEventAny *e);


          Gtk_Button          d_buttonOK,
                         d_buttonApply,
                         d_buttonCancel;
          char           *d_title,
                         *d_message;

     private:
          Gtk_Label      *d_defaultLabel;
          Gtk_HBox       *d_defaultHBox;
     };



GuiDialogOAC::GuiDialogOAC(char *title, char *message)
           : Gtk_Dialog (),
          d_buttonOK ("OK"),
          d_buttonApply ("Apply"),
          d_buttonCancel ("Cancel")
{
     printf ("+++ GuiDialogOAC\n");

     char           *s;

     if (title)
          s = title;
     else
          s = "GuiDialogOAC Window";

     d_title = strdup (s);
     d_message = message;

     this->position (GTK_WIN_POS_MOUSE);
}


GuiDialogOAC::~GuiDialogOAC()
{
     if (d_title) delete d_title;
     if (d_defaultLabel) delete d_defaultLabel;

     printf ("--- GuiDialogOAC\n");
}


void GuiDialogOAC::buildDialogWindow ()
{
     this->set_usize (300, 120);
     this->set_title (d_title);

     this->vbox()->border_width (2);

     fillVBox ();
     fillActionArea ();

     this->show ();
}


void GuiDialogOAC::fillVBox ()
{
     d_defaultHBox = new Gtk_HBox (TRUE, 5);
     d_defaultLabel = new Gtk_Label (d_message);
     d_defaultLabel->set_justify (GTK_JUSTIFY_LEFT);
     d_defaultLabel->set_padding (0, 0);
     d_defaultHBox->pack_start (d_defaultLabel);
     d_defaultLabel->show ();
     this->vbox()->pack_start (d_defaultHBox, TRUE, TRUE, 0);
     d_defaultHBox->show ();
}


void GuiDialogOAC::fillActionArea ()
{
     // create new hbox and add buttons to it
     connect_to_method (d_buttonOK.clicked, this, &buttonCallbackOK);
     this->action_area()->pack_start (&d_buttonOK, TRUE, TRUE, 0);
     d_buttonOK.show ();

     connect_to_method (d_buttonApply.clicked, this, &buttonCallbackApply);
     this->action_area()->pack_start (&d_buttonApply, TRUE, TRUE, 0);
     d_buttonApply.show ();

     connect_to_method (d_buttonCancel.clicked, this,
&buttonCallbackCancel);
     this->action_area()->pack_start (&d_buttonCancel, TRUE, TRUE, 0);
     d_buttonCancel.show ();
}


void GuiDialogOAC::buttonCallbackOK ()
{
     printf ("GuiDialogOAC: Default Callback OK\n");
}


void GuiDialogOAC::buttonCallbackApply ()
{
     printf ("GuiDialogOAC: Default Callback Apply\n");
}


void GuiDialogOAC::buttonCallbackCancel ()
{
     this->hide ();
     exit (0);
}


gint GuiDialogOAC::delete_event_impl(GdkEventAny *)
{
     this->hide ();
     return (0);
}


int main (int argc, char *argv[])
{
     Gtk_Main  gtkMain (&argc, &argv);
     GuiDialogOAC   *testDialog;
     GuiDialogOAC   *testDialog2;

     testDialog = new GuiDialogOAC ("Default Title", "Default Message");
     testDialog->buildDialogWindow ();
     testDialog->show ();
     testDialog2 = new GuiDialogOAC ("Default Title2", "Default Message2");
     testDialog2->buildDialogWindow ();
     testDialog2->show ();
     gtkMain.run ();
}




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