RE: dialog widget problem
- From: Matt Eisemann <meisemann dsrnet com>
- To: "'Dugas, Alan'" <alan dugas analog com>, "gtk-list gnome org" <gtk-list gnome org>
- Subject: RE: dialog widget problem
- Date: Wed, 1 Nov 2000 14:51:58 -0500
I did try the printf() comment but both numbers were the same. I also have
not tried the gtk_signal_emit_stop_by_name since the print statement (see
below) never executes in the gboolean ok_delete_handler(GtkWidget *widget,
GdkEvent *event,
> gpointer user_data)
The fact that the print statement in the function above never
executes, makes me think that it never gets in that function and I get a
core dump. I also have (but did not include before) a window_event_handler
which works great. Is there a difference in the way delete-event works for
main application windows and for dialog windows or not really?
gboolean window_event_handler(GtkWidget *widget, GdkEvent *event,
gpointer display_tasks);
The only difference I see is that I am told to use return FALSE for this
and return TRUE for a dialog window.
One other potential problem is that I do not use gtk_main() directly. I
have created my own event loop which has worked fine for other events.
While(tasks->running ==TRUE)
{
g_main_iteration(FALSE);
/* other event check iteration */
}
Any ideas? Thanks ahead of time for your help.
Matt
-----Original Message-----
From: Dugas, Alan [SMTP:alan dugas analog com]
Sent: Tuesday, October 31, 2000 11:35 AM
To: 'Dugas, Alan'; gtk-list gnome org; Matt Eisemann
Subject: RE: dialog widget problem
Hmm... It sounds like dialog_win might not be pointing to the widget you
want
when you set tasks->dialog_win. Use a debugger to check the value of
dialog_win
to see if it's changing. If you don't have a debugger available, insert
printf() statements to display the value of dialog_win after you create the
dialog window and again when you assign tasks->dialog_win = dialog_win,
they
should be the same. In addition to this, try using
gtk_widget_show(GTK_WIDGET(widget)) in ok_delete_handler(), it may also
help
shed some light on the problem. And lastly I think you may need to insert
a
call to gtk_signal_emit_stop_by_name() in ok_delete_handler() to prevent
the
default handler(s) from being run (see page195 of the GTK tutorial). It
could
be that a default handler is destroying your widget so that when you go to
use
it later (i.e. "show" it) you get a segfault.
-- Stupid Genius
> ----------
> From: Matt Eisemann[SMTP:meisemann dsrnet com]
> Sent: Tuesday, October 31, 2000 8:55 AM
> To: 'Dugas, Alan'; gtk-list gnome org
> Subject: RE: dialog widget problem
>
> Below should show my scoping of how I do everything. It must be a
scoping
> issue. Basically what I do is in two different functions I implement the
> following code to display the dialog under a specific condition.
>
> void some_func(void)
> {
> ....
> if(tasks->dead_tasks == TRUE)
> {
> gtk_widge_show_all(tasks->dialog_win);
> tasks->dead_tasks = FALSE;
> }
> }
>
> The above is seen in two different functions.
> In main() I have the code
>
> int main(int argc, char *argv[])
> {
> dialog_win = gtk_dialog_new();
> dialog_label = gtk_label_new("WARNING. There are DEAD tasks running.
");
> dialog_ok = gtk_button_new_with_label("OK");
> gtk_window_set_title(GTK_WINDOW(dialog_win), "dead tasks");
> gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_win)->vbox),dialog_label,
> FALSE,FALSE,NO_PADDING);
>
>
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_win)->action_area),dialog_ok,
> FALSE, FALSE,NO_PADDING);
> /* later in main this might be problem. copy ptr of widget to point
to
> dialog_win. Both are defined as GtkWidget *dialog_win. */
> tasks->dialog_win = dialog_win;
>
> /* callbacks then follow after the above */
>
> ....
> gtk_signal_connect_object(GTK_OBJECT(dialog_ok),"clicked",
>
> GTK_SIGNAL_FUNC(gtk_widget_hide
> ),GTK_OBJECT(dialog_win));
> gtk_signal_connect(GTK_OBJECT(tasks->dialog_win),"delete_event",
> GTK_SIGNAL_FUNC(ok_delete_handler),NULL);
>
> }
>
> The above signal does not make a difference, I get a core dump whether
I
> use GTK_OBJECT(tasks->dialog_win) or GTK_OBJECT(dialog_win). The
> utics_ok_delete_handler function
>
> gboolean ok_delete_handler(GtkWidget *widget, GdkEvent *event,
> gpointer user_data)
> {
> char who[]="ok_delete_handler";
>
> printf("closing: %s \n",who);
> gtk_widget_hide(widget);
> return(TRUE);
> }
>
> Hopefully the above should give the idea of the scoping I am using. The
> only problem I might see is the fact I make a copy of the ptr to the
widget
> but it should be displaying the same widget with just a different pointer
> unless I am wrong.
>
>
> -----Original Message-----
> From: Dugas, Alan [SMTP:alan dugas analog com]
> Sent: Monday, October 30, 2000 6:51 PM
> To: gtk-list gnome org; Matt Eisemann
> Subject: RE: dialog widget problem
>
> The code looks OK to me, however, you may be running into a scoping issue
> with dialog_win depending on where you use gtk_signal_connect().
> Otherwise,
> I think I'd need to see more of your code to figure out what's going on.
>
>
>
>
> -- Stupid Genius
> > ----------
> > From: Matt Eisemann[SMTP:meisemann dsrnet com]
> > Sent: Monday, October 30, 2000 6:23 PM
> > To: 'Dugas, Alan'; gtk-list gnome org
> > Subject: RE: dialog widget problem
> >
> > You were right. For some reason it needed gtk_signal_connect_object.
If
> > I
> > want to also have a window delete handler in case they close the window
> > via
> > window mgr does the following look right given the variable names I
have
> > used already.
> >
> > gtk_signal_connect(GTK_OBJECT(dialog_win),"delete_event",
> >
> >
> > GTK_SIGNAL_FUNC(utics_ok_delete_handler),NULL);
> >
> > gboolean utics_ok_delete_handler(GtkWidget *widget, GdkEvent *event,
> > gpointer user_data)
> > {
> > gtk_widget_hide(widget);
> > return(TRUE);
> > }
> >
> > Actually, i just tried it and I got a core dump. Anything look wrong
> > above. Thanks ahead of time for your help.
> >
> > Matt
> >
> >
> >
> > -----Original Message-----
> > From: Dugas, Alan [SMTP:alan dugas analog com]
> > Sent: Monday, October 30, 2000 5:58 PM
> > To: gtk-list gnome org; Matt Eisemann
> > Subject: RE: dialog widget problem
> >
> > Just a thought... It appears the problem has to do with
> > gtk_signal_connect()
> > passing it's first argument to gtk_widget_hide() whereas I think your
> > trying to
> > pass the last argument instead. Try using gtk_signal_connect_object(),
> it
> >
> > will
> > change the order of the argments passed to the callback function so
that
> > the
> > last argument to gtk_signal_connect_object() is passed as the first
> > argument to
> > gtk_widget_hide() instead.
> >
> >
> >
> > -- Stupid Genius
> >
> > > ----------
> > > From: Matt Eisemann[SMTP:meisemann dsrnet com]
> > > Sent: Monday, October 30, 2000 5:09 PM
> > > To: gtk-list gnome org
> > > Subject: dialog widget problem
> > >
> > > Currently I am creating an application, but there is something wrong
> > with
> > > the callback that hides the widget or something is wrong in my logic.
> > Here
> > > is a bit of code below which so should give some idea of what I am
> > doing.
> > > The main window calls a dialog box when a certain flag is set. I
want
> > the
> > > user to be able to push the "OK" button and hide the dialog window
and
> > > reset the flag back to FALSE. I hopefully left out extraneous
> > information
> > > and code.
> > >
> > > void some_function(... )
> > > {
> > >
> > > .....
> > >
> > >
> > >
> > > if(tasks->dead_tasks == TRUE)
> > > {
> > > gtk_widget_show_all(tasks->dialog_win);
> > > tasks->dead_tasks = FALSE;
> > > }
> > > }
> > >
> > >
> > >
> > > int main(INT argc, CHAR *argv[])
> > > {
> > > ...
> > > dialog_win = gtk_dialog_new();
> > > dialog_label = gtk_label_new("WARNING. There is something wrong.
> ");
> > > dialog_ok = gtk_button_new_with_label("OK");
> > > gtk_window_set_title(GTK_WINDOW(dialog_win),"dead tasks");
> > >
> > >
> gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_win)->vbox),dialog_label,F
> >
> > > ALSE,FALSE,NO_PADDING);
> > >
> gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_win)->action_area),dialog
> >
> > > _ok, FALSE,FALSE, NO_PADDING);
> > >
> > > gtk_signal_connect(GTK_OBJECT(dialog_ok),"clicked",
> > >
> > >
> GTK_SIGNAL_FUNC(gtk_widget_hide),GTK_OBJEC
> >
> > > T(dialog_win));
> > > }
> > > The code works somewthat above but the problem is that the OK
button
> > > disappears and not the whole window.
> > >
> > >
> > > _______________________________________________
> > > gtk-list mailing list
> > > gtk-list gnome org
> > > http://mail.gnome.org/mailman/listinfo/gtk-list
> > >
> >
> >
> > _______________________________________________
> > gtk-list mailing list
> > gtk-list gnome org
> > http://mail.gnome.org/mailman/listinfo/gtk-list
> >
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]