Re: [gedit-list] Exporting gedit_tab_save(_as)



Johannes Hölzl wrote:
Hi,

Am Donnerstag, den 15.06.2006, 10:31 +0200 schrieb Paolo Maggi:
Hi,
[..]
ATM, we expose public functions that plugins can use to open files, see the new public functions gedit_commands_load_uri and
gedit_commands_load_uris in gedit/gedit-commands.h (we still need to
bind them for python plugins).
We still need to expose functions for save/save_all. If you have time, you could try to write a patch to expose such
functionalities to plugins. Before implementing them, I'd suggest you to
post here the proposed function prototypes with the exact semantic you
expect for them.
I should check the code but I suspect there could be some problem when
trying to save_as a non-active document.

[..]
Ciao,
Paolo

Okay, the following patch exports the functions:

- gedit_commands_save_current_document(window)
- gedit_commands_save_documents_list(window, docs)
- gedit_commands_save_all_documents(window)

the semantics are the same as the _gedit_cmd_file_save_ ... functions.
If the user wants to wait until the files are saved, he needs to connect
to the "saved" signal. To avoid a dialog, the user should check if the
file is untitled.

Hi Johannes, thanks a lot for taking the time to prepare a patch.
Before getting to the details of the patch, I'd like to discuss the semantics of the proposed functions a little more.

In particular the issue of "Save As" that Paolo Maggi brought up: what happens when you run the save function on a untitled document which is not the active one?

I also don't like having a save_current_document() method: I prefer the api to explicitely specify the doc to save. If one needs to save the current doc he can easily get it or he can even simply activate the "save" GtkAction, which doesn't need any api addition (you get the action by name from the window ui manager and then simply g_signal_emit the activate signal on it.

I'd also avoid the save_all() variant for now, since I don't think it's widely used and the same GtkAction trick applies.

So basically I'd say that the api we need is
save_document() and save_documents() where the first is just a convenience function due to the fact that saving a single doc is more common. I am not sure if the functions should take GeditDocument, GeditView or GeditTab as args (it doesn't make much difference since they are in 1 to 1 relationship)


Now some minor details on the patch:
- the bound functions should go in a separate gedit.commands python module (you couldn't know this since the load functions are not bound yet, but that's how we decided to handle these functions since they differ from window methods)
- in then docs (very appreciated!) gedit should be spelled gedit not GEdit
- there are some minor coding style issues (we put spaces before the '(' and stuff like that)



Paolo



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]