Recent

Author Topic: Open as Project or XML  (Read 2216 times)

narag

  • New member
  • *
  • Posts: 7
Open as Project or XML
« on: February 23, 2018, 10:48:05 am »
Hello,

I've been searching for a while, found nothing, seems weird nobody asked before.

Every time I open a project, a dialog pops up asking me if I want to open the project as a project or as xml file. Of course I want to open the project as a project, why would I been using Lazarus otherwise?  :o

Tried to circumvent the annoyance opening the lpr instead of lpi. No luck. Now there's a dialog asking me if I want to open a project as a project or as a "normal source" :o

Is there a way to open a Lazarus project without being asked if I want to open a Lazarus project? I've searched the options for some way to disable the dialogs, but I didn't find anything :(

Thanks in advance,

    Nico

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: Open as Project or XML
« Reply #1 on: February 23, 2018, 10:50:51 am »
Open the lpr, not the lpi....?

Let me explain:
- the lpi IS xml so should be able to be editted as xml.
- the lpr file is a pascal file and free of ambiguities.
- the lpi will be loaded anyway. (And someone made a bad design decision here...leading to such questions: why not always open as project, unless right-click-open as xml: which has more logic, no question and the least likely case is still implemented)
- it is possible on most - but afaik not all - platforms to associate lpi files with the Lazarus editor.
« Last Edit: February 23, 2018, 11:04:17 am by Thaddy »
Specialize a type, not a var.

narag

  • New member
  • *
  • Posts: 7
Re: Open as Project or XML
« Reply #2 on: February 23, 2018, 11:13:57 am »
Hi Thaddy,

>the lpi IS xml so should be able to be editted as xml.

I disagree. If you need to bypass the IDE and edit the lpi manually, just use any regular text editor. Would it be nice to *also* open it with the IDE as XML? Well, maybe. But that can't be an excuse to show that dialog that gets in the way for using the *main* file type associated with an application the way it was intended to work.

What would you think of a video player that, every time you wanted to open a video file, asked you if you want to play the video or open the file with a hexadecimal editor? Or if an Office application asked if you want to open a docx as a document or with Notepad to edit the underlying XML?

>the lpr file is a pascal file and free of ambiguities.

The IDE wants to know if I want to open a project or just open it as a "normal source", thus not closing the current project. Actually the same problem and the same reasoning.  The fringe case stomps on the regular 99% of times usage.

There are several ways to handle this, I have no preferences as long as I can somehow disable the dialog and open lpis right away.

salu2

   Nico
 

narag

  • New member
  • *
  • Posts: 7
Re: Open as Project or XML
« Reply #3 on: February 23, 2018, 11:21:24 am »
No preferences but I should offer at least one solution in case there isn't an option in the config: an "Open as plain text" option in the File menu.

rvk

  • Hero Member
  • *****
  • Posts: 6109
Re: Open as Project or XML
« Reply #4 on: February 23, 2018, 11:51:27 am »
But why are you opening the .lpi via the menu File > Open?
If you do it via Project > Open Project and open the .lpi you won't get such message.
Opening it in File > Open it could be that you want to open it as xml.
(Even opening it via the explorer via file association the project opens fine if you open the .lpi, at least in Laz 1.8+)

You can of course hack Lazarus yourself and force the opening as project.
The dialog is in lazarus\ide\sourcefilemanager.pas.
Search for lisOpenAsXmlFile and you see the dialogs you can remove.
(so you only end up with MainIDE.DoOpenProjectFile() for the lpi and PkgBoss.DoOpenPackageFile() for the lpk files)

You can also always put in a feature request to make this default and settable in settings.

Code: Pascal  [Select][+][-]
  1.   // check for special files
  2.   if ([ofRegularFile,ofRevert,ofProjectLoading]*FFlags=[])
  3.   and FilenameIsAbsolute(FFilename) and FileExistsCached(FFilename) then begin
  4.     // check if file is a lazarus project (.lpi)
  5.     if (CompareFileExt(FFilename,'.lpi',false)=0) then
  6.     begin
  7.       case
  8.         IDEQuestionDialog(lisOpenProject, Format(lisOpenTheProject, [FFilename]),
  9.             mtConfirmation, [mrYes, lisOpenProject2,
  10.                              mrNoToAll, lisOpenAsXmlFile,
  11.                              mrCancel])
  12.       of
  13.         mrYes: begin
  14.           Result:=MainIDE.DoOpenProjectFile(FFilename,[ofAddToRecent]);
  15.           exit;
  16.         end;
  17.         mrNoToAll: include(FFlags, ofRegularFile);
  18.         mrCancel: exit(mrCancel);
  19.       end;
  20.     end;
  21.  
  22.     // check if file is a lazarus package (.lpk)
  23.     if (CompareFileExt(FFilename,'.lpk',false)=0) then
  24.     begin
  25.       case
  26.         IDEQuestionDialog(lisOpenPackage,
  27.             Format(lisOpenThePackage, [FFilename]),
  28.             mtConfirmation, [mrYes, lisCompPalOpenPackage,
  29.                              mrNoToAll, lisOpenAsXmlFile,
  30.                              mrCancel])
  31.       of
  32.         mrYes: begin
  33.           Result:=PkgBoss.DoOpenPackageFile(FFilename,[pofAddToRecent],
  34.                                        [ofProjectLoading,ofMultiOpen]*FFlags<>[]);
  35.           exit;
  36.         end;
  37.         mrCancel: exit(mrCancel);
  38.       end;
  39.     end;
  40.   end;

narag

  • New member
  • *
  • Posts: 7
Re: Open as Project or XML
« Reply #5 on: February 23, 2018, 12:07:08 pm »
Hi,

>If you do it via Project > Open Project and open the .lpi you won't get such message.

Thank you, that works! :)


 

TinyPortal © 2005-2018