[Geany-devel] [PATCH] Open files in Geany at the same workspace

Colomban Wendling lists.ban at xxxxx
Thu Oct 7 17:04:04 UTC 2010


Le 07/10/2010 16:17, Nick Treleaven a écrit :
> On Wed, 29 Sep 2010 18:00:06 +0100
> Nick Treleaven <nick.treleaven at btinternet.com> wrote:
> 
>>>> 3) this is the most complicated but also the one that seems to have the
>>>> less flaws: still add workspace suffix, but when checking if there is a
>>>> running instance to which send the requests, ignore that workspace
>>>> information if the pre-workspace option is not checked. It needs to list
>>>> the available socket(s), and then select the one we want (probably the
>>>> first or the one closets to the current desktop), but it fixes flaws I
>>>> see in both methods 1) and 2).
>>>
>>> I prefer this solution, mainly because it doesn't have the problems the
>>> other two solutions have.
>>
>> In any case, the patch introduced a bug where 2nd instances still load
>> the session files. So I think we'll need to revert it until there's a
>> fix.
> 
> I've now copied the code to branches/workspace-sockets and reverted the
> code in trunk. Hopefully we can fix the issues and merge back
> sometime.
Cool (for me :D), I'd also think it needs a little more incubation.
IMO the current design is a bit flawed since if the instance is moved to
another workspace, it still behaves as if on its original workspace.
Not sure how this could be fixed, but it needs to be fixed before
merging to trunk IMO.

I don't know what's possible to do, but I see some possibilities:

1) Detect workspace change, and then change socket name. This is not
really easy since it needs handling the case when there is already an
instance on this workspace.

2) When trying to open a file on a running instance, ask its workspace
before actually sending the commands. This needs to list existing
sockets and add a way to communicate the workspace through it. But then,
this would look like:
	socket = None
	for s in socket_list:
		if s.workspace == current_workspace:
			socket = s
			break
	if socket is not None:
		socket.send_command(...)
	else:
		open_new_instance()
Note that the sockets no longer should be workspace-suffixed, since this
workspace ID would sometime be wrong. Better use a random/incrementing
suffix.

Perhaps a look at how GEdit handles this would provide some ideas?

> One idea besides having a pref for this is to have a command-line option
> to use the 'main' socket instead of the current workspace.
Why not, but it's not really convenient for those who use launchers:
they need to be modified. But it would fix the problem that the prefs
are currently loaded *after* socket checks.

BTW, I join the first patch I did to implement my 3rd proposal so if
anybody's interested, they can take a look. I run it since I wrote it (a
week ago), and seems to work fine -- apart the pref that is not loaded
at the time I use it.

Regards,
Colomban
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-per-workspace-instances-pref-impl3.patch
Type: text/x-patch
Size: 5007 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20101007/c2aa285d/attachment.bin>


More information about the Devel mailing list