Hi i am writing an app and i'm not sure how to deal with sensitivity of cut paste, and delete, actions.
I did the following provisionally. primcb=gtk_widget_get_clipboard(mainwindow, GDK_SELECTION_PRIMARY); g_signal_connect(G_OBJECT (primcb),"owner-change", G_CALLBACK(ownerchange_primary_cb),NULL); THere are three objects which might have selectable areas. The textbuffers, proof_buffer->text_buf and msg_buf, as well as the GtkTextEntry escape_entry. proof_buffer->text_buf, and escape_entry are editable by the user, and msg_buf is not. With this in mind for the handler "ownwerchange_primary_cb" I did something like this (for cut copy, and paste sensitivity) static void ownerchange_primary_cb(GtkClipboard *clipboard, GdkEvent *event, gpointer user_data){ GObject *owner=gtk_clipboard_get_owner (clipboard); if(owner != NULL){ if (owner == G_OBJECT (proof_buffer->text_buf)){ //printf("owner is proof buffer!\n"); gtk_action_group_set_sensitive(cutdel_actiongroup,TRUE); gtk_action_group_set_sensitive(copy_actiongroup,TRUE); }else if (owner==G_OBJECT(msg_buf)){ //printf("owner is message buffer\n"); gtk_action_group_set_sensitive(cutdel_actiongroup,FALSE); gtk_action_group_set_sensitive(copy_actiongroup,TRUE); }else if(owner==G_OBJECT(escape_entry)){ gtk_action_group_set_sensitive(cutdel_actiongroup,TRUE); gtk_action_group_set_sensitive(copy_actiongroup,TRUE); //printf("owner is escape entry\n"); }else{ gtk_action_group_set_sensitive(cutdel_actiongroup,FALSE); gtk_action_group_set_sensitive(copy_actiongroup,FALSE); //printf("don't know owner!\n"); } } else{ gtk_action_group_set_sensitive(cutdel_actiongroup,FALSE); gtk_action_group_set_sensitive(copy_actiongroup,FALSE); } } For paste sensitivity i did this: g_signal_connect(G_OBJECT (mainwindow),"set-focus", G_CALLBACK(mainwin_focus_set),NULL); mainwindow is a window btw. The handler "mainwin_focus_set" is this: static void mainwin_focus_set(GtkWindow *window, GtkWidget *widget, gpointer user_data){ if(widget==mainview){ //printf("main view focused on\n"); gtk_action_group_set_sensitive(paste_actiongroup,TRUE); }else if (widget==messageview){ gtk_action_group_set_sensitive(paste_actiongroup,FALSE); //printf("message view focused on\n"); }else if(widget==escape_entry){ gtk_action_group_set_sensitive(paste_actiongroup,TRUE); //printf("escape entry focuse upon\n"); }else{ gtk_action_group_set_sensitive(paste_actiongroup,FALSE); //printf("unknown focus\n"); } } So can anyone tell me if i've dealt with action sensitivity the right way? Your help will be muchly appreciated. Thank you very much, --Bikhu _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list