Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
gtk_widget_destroy does not work.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
dE_logics
Advocate
Advocate


Joined: 02 Jan 2009
Posts: 2253
Location: $TERM

PostPosted: Tue May 28, 2013 6:08 am    Post subject: gtk_widget_destroy does not work. Reply with quote

I'm having a hard time getting this to work. :x

On clicking of a button on GtkDialog, the Dialog should close. But nothing happens. I even tried to destroy other widgets including buttons, and containers, but absolutely nothing --

gboolean close_window ( GtkWidget *temp , GdkEvent *event, gpointer *target ) {
gtk_widget_destroy ( *target );
}

Using Glade with C.

I really need help on this one.
_________________
My blog
Back to top
View user's profile Send private message
VoidMage
Watchman
Watchman


Joined: 14 Oct 2006
Posts: 6194

PostPosted: Tue May 28, 2013 6:22 am    Post subject: Reply with quote

Usually, you deal with dialogs by connecting to 'response' signal.
The line or two you've posted seems to do it in an odd way.
Back to top
View user's profile Send private message
dE_logics
Advocate
Advocate


Joined: 02 Jan 2009
Posts: 2253
Location: $TERM

PostPosted: Tue May 28, 2013 7:26 am    Post subject: Reply with quote

I'll try doing that, but this also should work right?
_________________
My blog
Back to top
View user's profile Send private message
mir3x
Guru
Guru


Joined: 02 Jun 2012
Posts: 453

PostPosted: Tue May 28, 2013 3:07 pm    Post subject: mir3x Reply with quote

Haven't programmed in gtk,
but it looks like it should be
gtk_widget_destroy (temp)
or
gtk_widget_destroy(target)
or maybe u should cast that pointer to gtkwidget first ?
_________________
Sent from Windows
Back to top
View user's profile Send private message
dE_logics
Advocate
Advocate


Joined: 02 Jan 2009
Posts: 2253
Location: $TERM

PostPosted: Tue May 28, 2013 3:39 pm    Post subject: Re: mir3x Reply with quote

mir3x wrote:
Haven't programmed in gtk,
but it looks like it should be
gtk_widget_destroy (temp)
or
gtk_widget_destroy(target)
or maybe u should cast that pointer to gtkwidget first ?


gtk_widget_destroy does not accept variable of type gpointer, but *gpointer points to a variable which of type GtkWidget.
_________________
My blog
Back to top
View user's profile Send private message
mir3x
Guru
Guru


Joined: 02 Jun 2012
Posts: 453

PostPosted: Tue May 28, 2013 5:54 pm    Post subject: Reply with quote

Im not good in those pointers to pointers but it looks for me like :
gpointer points -> gtkwidget *x;

so gpointer* points to -> gtkwidget **x

but u need to pass only gtkwidget x, not gtkwidget **x

maybe u assigned it in wrong way ?
should be like this:
GtkWidget *x;
gpointer y;

y =&x;
gtk_widget_destroy((GtkWidget*) x);
_________________
Sent from Windows
Back to top
View user's profile Send private message
VoidMage
Watchman
Watchman


Joined: 14 Oct 2006
Posts: 6194

PostPosted: Tue May 28, 2013 8:02 pm    Post subject: Reply with quote

Sorry, but I need to ask: did you at least read description of GtkDialog from gtk+ docs and the example of dialog from gtk-demo ?
Back to top
View user's profile Send private message
dE_logics
Advocate
Advocate


Joined: 02 Jan 2009
Posts: 2253
Location: $TERM

PostPosted: Wed May 29, 2013 5:18 am    Post subject: Reply with quote

mir3x wrote:
Im not good in those pointers to pointers but it looks for me like :
gpointer points -> gtkwidget *x;

so gpointer* points to -> gtkwidget **x

but u need to pass only gtkwidget x, not gtkwidget **x

maybe u assigned it in wrong way ?
should be like this:
GtkWidget *x;
gpointer y;

y =&x;
gtk_widget_destroy((GtkWidget*) x);


IT WORKED!!! THANK YOU!! :) :) :D

However that's strange, cause when I do that, I get --

gtk_frontend.c:97:2: warning: passing argument 1 of 'gtk_widget_destroy' from incompatible pointer type [enabled by default]
In file included from /usr/include/gtk-3.0/gtk/gtkapplication.h:27:0,
from /usr/include/gtk-3.0/gtk/gtkwindow.h:33,
from /usr/include/gtk-3.0/gtk/gtkdialog.h:33,
from /usr/include/gtk-3.0/gtk/gtkaboutdialog.h:30,
from /usr/include/gtk-3.0/gtk/gtk.h:31,
from gtk_frontend.c:1:
/usr/include/gtk-3.0/gtk/gtkwidget.h:447:9: note: expected 'struct GtkWidget *' but argument is of type 'void **'

So finally gtk_widget_destroy ( target ); worked as apposed to *target,

gtk_widget_destroy accepts Gtkwidget, so target should actually be of type *Gtkwidget.
_________________
My blog
Back to top
View user's profile Send private message
dE_logics
Advocate
Advocate


Joined: 02 Jan 2009
Posts: 2253
Location: $TERM

PostPosted: Wed May 29, 2013 6:06 am    Post subject: Reply with quote

VoidMage wrote:
Sorry, but I need to ask: did you at least read description of GtkDialog from gtk+ docs and the example of dialog from gtk-demo ?


GtkDialog is a child of GtkWidget, so it doesnt have a dedicated way to close windows, so we have to use GtkWidget for the purpose.

gtk-demo? Never heard of that. But you know, I'm using glade, so I don't know how to make widgets and moving them around (packing) in containers. Neither I know connecting signals, since that's handled by Glade, but most of the tutorials start from GTK scratch, not with Glade.
_________________
My blog
Back to top
View user's profile Send private message
mir3x
Guru
Guru


Joined: 02 Jun 2012
Posts: 453

PostPosted: Wed May 29, 2013 7:42 am    Post subject: Reply with quote

>> /usr/include/gtk-3.0/gtk/gtkwidget.h:447:9: note: expected 'struct GtkWidget *' but argument is of type 'void **'

u have to cast it to gtkwidget*, then warning will disappear.

if u ever post code somewhere, reader will know what r u trying to achieve, and compiler too :D
_________________
Sent from Windows
Back to top
View user's profile Send private message
VoidMage
Watchman
Watchman


Joined: 14 Oct 2006
Posts: 6194

PostPosted: Wed May 29, 2013 12:21 pm    Post subject: Reply with quote

Those tutorials start from scratch for a very good reason, that you've just demonstrated.
Understanding on at least basic level which signals are useful in an exact context leads to a better code (sometimes it required to make things work at all).
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum