Re: Paste should be insensitive when unavailable - but when?

Dave Malcolm <[email protected]> 06 Jan 2004 21:39:54 +0000
Newsgroups gmane.editors.conglomerate.general
Message-ID <1073425193.6325.20.camel@shirehorse1>
On Tue, 2004-01-06 at 19:51, Paul Smith wrote:
> I tried a reply to this earlier today, but it seems to have gotten lost
> in CyberSpace somewhere, so here's take 2
> 
> There are 2 problems with the patchthe I have for this:
> 
> What the patch does:
> 
> Sets sensitivity of the Paste button/toolbar/context menu depending on
> the results of cong_document_can_paste(CongDocument*)

It would be nice to have the code to do this, even if we can't yet use
it effectively.

> 
> What the patch does not do:
> 
> Actually assess whether pasting is available, as
> cong_document_can_paste always returns TRUE;
> Attach to any signal to re-assess pastability at an opportune moment.
> 
> So, I need some pointers here.  What conditions should actually be
> checked here?  I'm guessing things like cursor should be a valid
> position, probably should check cong_range_can_be_cut if there is a
> selection?

You should look at the paste routine and test for all the conditions in
which it can fail.  Look in src/xmledit.c, in function
cong_document_paste_clipboard_or_selection, and potentially in the
functions it calls.

> 
> Once I have some idea of what needs checking, I'd need to know (but
> could probably guess) when it needs rechecking.  Last time round I
> remember Dave mentioning that X sends out a signal when clipboard
> contents change, does anyone know where I can get any more information
> from on this?

I'm now a lot more knowledgable on how the X clipboard works, so I can
have a look into this if you like.

> 
> As for current signals in Conglomerate, which of these could
> pontentially alter the sensitivity of Paste?
> 
> cong-command-history.c: "changed",
> cong-document.c:        "begin_edit",
> cong-document.c:        "end_edit",
> cong-document.c:        "node_make_orphan",
> cong-document.c:        "node_add_after",
> cong-document.c:        "node_add_before",
> cong-document.c:        "node_set_parent",
> cong-document.c:        "node_set_text",
> cong-document.c:        "node_set_attribute",
> cong-document.c:        "node_remove_attribute",
> cong-document.c:        "selection_change",
> cong-document.c:        "cursor_change",
> cong-document.c:        "set_dtd_ptr",
> cong-document-traversal.c:      "traversal_node_added",
> cong-document-traversal.c:      "traversal_node_removed",
> cong-editor-area.c:     "button_press_event",
> cong-editor-area.c:     "enter_notify_event",
> cong-editor-area.c:     "leave_notify_event",
> cong-editor-area.c:     "motion_notify_event",
> cong-editor-area.c:     "key_press_event",
> cong-editor-area.c:     "flush_requisition_cache",
> cong-editor-area.c:     "state_changed",
> cong-editor-area-container.c:   "children_changed",
> cong-editor-area-expander.c:    "expansion_changed",
> cong-editor-node.c:     "line_regeneration_required",
> cong-editor-node.c:     "is_selected_changed",
> cong-xpath-expression.c:        "string_result_changed",
> plugin-lists-node-element-listitem.c:   "label_changed"

Looking at cong_document_paste_clipboard_or_selection, it looks like
it'll be affected by CongDocument "cursor_change", and by whatever
signal we can set up to monitor the X clipboard.

> 
> Should I attach the patch to Bugzilla anyway?

Yes please, with an appropriate comment.

Thanks!

Dave

> 
>  --- [email protected] wrote: > Please do not reply to
> this email- if you want to comment on the bug,
> > go to the
> > URL shown below and enter your comments there.
> > 
> > http://bugzilla.gnome.org/show_bug.cgi?id=126089
> > 
> > Changed by [email protected].
> > 
> > --- shadow/126089	Mon Nov  3 05:16:02 2003
> > +++ shadow/126089.tmp.2459	Mon Jan  5 21:16:19 2004
> > @@ -1,12 +1,12 @@
> >  Bug#: 126089
> >  Product: conglomerate
> >  Version: cvs
> >  OS: Linux
> >  OS Details: 
> > -Status: NEW   
> > +Status: NEEDINFO   
> >  Resolution: 
> >  Severity: normal
> >  Priority: Normal
> >  Component: Code
> >  AssignedTo: [email protected]                     
> >       
> >  ReportedBy: [email protected]               
> > @@ -18,6 +18,11 @@
> >  pasting is not possible.  I have a patch which does some of the
> > work, and
> >  I'm waiting for Anon CVS to catch up before submitting it.
> >  
> >  However, the conditions for pasting to be possible are not complete,
> > and
> >  should be recalculated when clipboard contents change (this one
> > requires a
> >  new signal somewhere)
> > +
> > +------- Additional Comments From [email protected] 
> > 2004-01-05 21:16 -------
> > +Do you still have that patch?  I suspect that it might no longer be
> > +directly applicable as I did a big rewrite of the clipboard handling
> > +for 0.7.9  But it'd be worth seeing in any case.
> > 
> > _______________________________________________
> > Conglomerate-auto mailing list
> > [email protected]
> > http://lists.copyleft.no/mailman/listinfo/conglomerate-auto
> 
> =====
> -----------------------------------------------------
> Paul Smith
> Postgraduate Student
> Department of Mathematics
> School of Engineering, Computer Science,
>                             and Mathematics
> University of Exeter
> 
> ________________________________________________________________________
> Yahoo! Messenger - Communicate instantly..."Ping" 
> your friends today! Download Messenger Now 
> http://uk.messenger.yahoo.com/download/index.html
> 
> _______________________________________________
> Conglomerate mailing list
> [email protected]
> http://lists.copyleft.no/mailman/listinfo/conglomerate
-- 
David Malcolm
www.conglomerate.org