On Wed, 29 Sep 2010 18:00:06 +0100
Nick Treleaven <[email protected]> wrote:
> On Wed, 29 Sep 2010 09:52:19 +1000
> Erik de Castro Lopo <[email protected]> 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.
So both require traversing the possible sockets. It can be something
like this <attachment>. But I'd personally prefer the patch removed...
--
E-gards: Jimmy
gboolean load_default_session = TRUE;
preference open_files_on_same_workspace;
socket.c: socket_init()
...
#ifdef G_OS_WIN32
...remains the same, ui_get_current_workspace() ::= 0
#else
if (socket_info.file_name == NULL)
{
gchar *display_name = gdk_get_display();
gint workspace = ui_get_current_workspace(display_name);
int workspace_count = ui_get_workspace_count(display_name);
/* new */
gchar *hostname = utils_get_hostname();
...prepare display_name, host_name etc...
socket_info.file_name =
g_strdup_printf("%s%cgeany_socket_%s_%s_ws%d",
app->configdir, G_DIR_SEPARATOR, hostname,
display_name, workspace);
if (open_files_on_same_workspace)
{
check_socket_permissions(socket_info.file_name);
sock = socket_fd_connect_unix(socket_info.file_name);
/* don't check for a socket if the default session
won't be loaded anyway */
if (sock < 0 && cl_options.load_session)
{
int ws;
for (ws = 0; ws < workspace_count; ws++)
{
gchar *name;
int sk;
if (ws == workspace)
continue;
name = g_strdup_printf(..., ws);
check_socket_permissions(sock_name);
sk = socket_connect(sock_name);
gfree(name);
if (sk >= 0)
{
socket_close(sk);
/* cl_options.load_session
can't be used, so... */
load_default_session = FALSE;
break;
}
}
}
}
else /* first workspace (may actually be > current
workspace) */
{
int ws;
for (ws = 0; ws < workspace_count; ws++)
{
gchar *sock_name = g_strdup_printf(..., ws);
check_socket_permissions(sock_name);
sock =
socket_fd_connect_unix(socket_info.file_name);
if (sock >= 0)
{
g_free(socket_info.file_name);
socket_info.file_name = sock_name;
break;
}
gfree(sock_name);
}
}
g_free(display_name);
g_free(hostname);
}
else /* socket name specified */
{
check_socket_permissions(socket_info.file_name);
sock = socket_fd_connect_unix(socket_info.file_name);
}
if (sock < 0)
{
remove_socket_link_full(); /* deletes the socket file and the
symlink */
return socket_fd_open_unix(socket_info.file_name);
}
#endif
...
main.c: load_startup_files()
...
if (prefs.load_session)
{
if (load_project_from_cl)
{
main_load_project_from_command_line(argv[1],
FALSE);
}
else if (cl_options.load_session &&
load_default_session)
load_session_project_file();
/* when we want a new instance, we still load project
session files unless -s
* was passed */
if (!cl_options.load_session || (!load_project_from_cl
&& !load_default_session))
return;
/* load session files into tabs, as they are found in
the session_files variable */
configuration_open_files();
...
_______________________________________________
Geany-devel mailing list
[email protected]
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel