GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Wed Jul 30, 2014 5:12 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Menu Item Sensitivity
PostPosted: Thu Jan 12, 2012 3:49 pm 
Offline

Joined: Thu Jan 12, 2012 3:42 pm
Posts: 3
Hey. I am trying to get the sensitivity of a menu to change depending on the focus of a text view. I keep getting an error:

Code:
GTK_IS_WIDGET(widget) failed


I have a signal called on_textview_debug_focus_in_event that runs this:
Code:
void
on_textview_debug_focus_out_event(GtkWidget *widget, HostsEditor *editor)
{
   gtk_widget_set_sensitive(GTK_WIDGET(editor->mnu_edit_copy), FALSE);
   gtk_widget_set_sensitive(GTK_WIDGET(editor->mnu_edit_paste), FALSE);
   gtk_widget_set_sensitive(GTK_WIDGET(editor->mnu_edit_cut), FALSE);
   gtk_widget_set_sensitive(GTK_WIDGET(editor->mnu_edit_delete), FALSE);
}


I am pretty stuck with this one. It doesn't matter if I change it from GtkWidget to GtkImageMenuItem etc I keep getting the same results.

Thanks for any help.


Top
 Profile  
 
 Post subject: Re: Menu Item Sensitivity
PostPosted: Fri Jan 13, 2012 10:12 am 
Offline
Never Seen the Sunlight

Joined: Wed Jul 23, 2008 10:31 am
Posts: 2406
Location: Slovenia
Hello and welcome to the GTK+ forums!

If I'm not mistaken, you have your signal handler connected to GtkWidget::focus-in-event, in which case your function has a bad header. As you can see from the docs I linked to, your function prototype should look something like this:
Code:
static gboolean
on_textview_debug_focus_out_event (GtkWidget   *widget,
                                   GdkEvent    *event,
                                   HostsEditor *editor)

Try changing this and I'm almost sure things will work as expected.

Cheers,
Tadej


Top
 Profile  
 
 Post subject: Re: Menu Item Sensitivity
PostPosted: Fri Jan 13, 2012 12:10 pm 
Offline

Joined: Thu Jan 12, 2012 3:42 pm
Posts: 3
Thanks Tadej. Worked a treat. Can't believe I didn't spot that in the docs, sorry!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [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