John Levon wrote:

> On Thu, Feb 20, 2003 at 12:59:32PM +0000, Angus Leeming wrote:
> 
>> > Since you're working in this  stuff, can you bear in mind the mooted
>> > "edit-properties" ? It would be nice if this was worked into your new
>> > framework.
>> 
>> Care to remind me what it is?
> 
> Sorry. We want a generic ability to be able to have an lfun:
> 
> edit-properties tabular
> edit-properties url
> 
> etc. which will only be enabled if we're inside that kind of inset, or
> the cursor is next to one. Basically, it would bring up the associated
> dialog where there is one, or be disabled otherwise
> 
> regards
> john

So far I have this (bottom). 

You need an LFUN_SHOW_DIALOG_NEXT that finds the desired inset and then 
opens the dialog. You could either call Dialogs::show direct as:
        owner->getDialogs().show(name, data, inset);
where 'data' is a string of the stuff you wish to edit which can be 
'translated' by the frontend or you could do as I have done for the 
InsetCommand insets and define a 'Mailer' that does the dirty work for you. 
In that case your LFUN becomes:

        case LFUN_SHOW_DIALOG_NEXT: {
                string const name = cmd.argument;
                Inset * inset = nextInset(name);
                MailInset * mailer = 0;
                if (inset) {
                        if (isCommandInset(inset)) {
                                // exits already
                                mailer = new InsetCommandMailer(name, *inset);
                        } else if (isTabularInset(inset)) {
                                // hypothetical
                                mailer = new InsetTabularMailer(*inset);
                        }
                }
                if (mailer) {
                        mailer.showDialog();
                        delete mailer;
                }
        }
        break;

So, you need to define 'nextInset' and 'isCommandInset' or its equivalent 
and you're away. The frontend code is complete in this regard.

Angus



        case LFUN_DIALOG_SHOW_NEW: {
                string const name = cmd.argument;
                string data;
                if (name == "citation") {
                        InsetCommandParams p("cite");
                        data = InsetCommandMailer::params2string(p);
                }
                owner->getDialogs().show(name, data, 0);
        }
        break;

        case LFUN_DIALOG_UPDATE: {
                string const name = cmd.argument;
                string data;
                if (name == "citation") {
                        InsetCommandParams p("cite");
                        data = InsetCommandMailer::params2string(p);
                }
                owner->getDialogs().update(name, data);
        }
        break;

        case LFUN_DIALOG_HIDE:
                owner->getDialogs().hide(cmd.argument);
                break;

        case LFUN_DIALOG_DISCONNECT:
                owner->getDialogs().disconnect(argument);
                break;

-- 
Angus

Reply via email to