app/unique.c on Win32, if the gimp binary is started without filenames,

2008-07-13  Sven Neumann  <sven@gimp.org>

	* app/unique.c
	* app/gui/gui-unique.c: on Win32, if the gimp binary is started
	without filenames, raise the toolbox, just as we do in the DBus
	code path.


svn path=/trunk/; revision=26183
This commit is contained in:
Sven Neumann 2008-07-13 19:04:38 +00:00 committed by Sven Neumann
parent 8746d0d0b7
commit e6e549a2d6
3 changed files with 78 additions and 43 deletions

View File

@ -1,3 +1,10 @@
2008-07-13 Sven Neumann <sven@gimp.org>
* app/unique.c
* app/gui/gui-unique.c: on Win32, if the gimp binary is started
without filenames, raise the toolbox, just as we do in the DBus
code path.
2008-07-13 Aurimas Juška <aurisj@svn.gnome.org>
* app/unique.c (gimp_unique_win32_open): check for NULL pointer to

View File

@ -128,12 +128,16 @@ typedef struct
static IdleOpenData *
idle_open_data_new (const gchar *name,
gint len,
gboolean as_new)
{
IdleOpenData *data = g_slice_new (IdleOpenData);
IdleOpenData *data = g_slice_new0 (IdleOpenData);
data->name = g_strdup (name);
data->as_new = as_new;
if (len > 0)
{
data->name = g_strdup (name);
data->as_new = as_new;
}
return data;
}
@ -148,7 +152,19 @@ idle_open_data_free (IdleOpenData *data)
static gboolean
gui_unique_win32_idle_open (IdleOpenData *data)
{
file_open_from_command_line (unique_gimp, data->name, data->as_new);
if (data->name)
{
file_open_from_command_line (unique_gimp, data->name, data->as_new);
}
else
{
/* raise the toolbox */
const GList *managers = gimp_ui_managers_from_name ("<Image>");
if (managers)
gimp_ui_manager_activate_action (managers->data,
"dialogs", "dialogs-toolbox");
}
return FALSE;
}
@ -163,27 +179,28 @@ gui_unique_win32_message_handler (HWND hWnd,
switch (uMsg)
{
case WM_COPYDATA:
{
COPYDATASTRUCT *copydata = (COPYDATASTRUCT *) lParam;
if (unique_gimp)
{
COPYDATASTRUCT *copydata = (COPYDATASTRUCT *) lParam;
GSource *source;
GClosure *closure;
IdleOpenData *data;
if (unique_gimp && copydata->cbData > 0)
{
GSource *source;
GClosure *closure;
IdleOpenData *data = idle_open_data_new (copydata->lpData, copydata->dwData != 0);
data = idle_open_data_new (copydata->lpData,
copydata->cbData,
copydata->dwData != 0);
closure = g_cclosure_new (G_CALLBACK (gui_unique_win32_idle_open),
data,
(GClosureNotify) idle_open_data_free);
closure = g_cclosure_new (G_CALLBACK (gui_unique_win32_idle_open),
data,
(GClosureNotify) idle_open_data_free);
g_object_watch_closure (unique_gimp, closure);
g_object_watch_closure (unique_gimp, closure);
source = g_idle_source_new ();
g_source_set_closure (source, closure);
g_source_attach (source, NULL);
g_source_unref (source);
}
}
source = g_idle_source_new ();
g_source_set_closure (source, closure);
g_source_attach (source, NULL);
g_source_unref (source);
}
return TRUE;
default:

View File

@ -188,32 +188,43 @@ gimp_unique_win32_open (const gchar **filenames,
if (window_handle)
{
COPYDATASTRUCT copydata;
gchar *cwd = g_get_current_dir ();
GError *error = NULL;
gint i;
COPYDATASTRUCT copydata = { 0, };
for (i = 0; filenames && filenames[i]; i++)
{
gchar *uri = gimp_unique_filename_to_uri (filenames[i], cwd, &error);
if (filenames)
{
gchar *cwd = g_get_current_dir ();
GError *error = NULL;
gint i;
if (uri)
{
copydata.lpData = uri;
copydata.cbData = strlen (uri) + 1; /* size in bytes */
copydata.dwData = (long) as_new;
for (i = 0; filenames[i]; i++)
{
gchar *uri;
SendMessage (window_handle,
WM_COPYDATA, window_handle, &copydata);
}
else
{
g_printerr ("conversion to uri failed: %s\n", error->message);
g_clear_error (&error);
}
}
uri = gimp_unique_filename_to_uri (filenames[i], cwd, &error);
g_free (cwd);
if (uri)
{
copydata.lpData = uri;
copydata.cbData = strlen (uri) + 1; /* size in bytes */
copydata.dwData = (long) as_new;
SendMessage (window_handle,
WM_COPYDATA, window_handle, &copydata);
}
else
{
g_printerr ("conversion to uri failed: %s\n", error->message);
g_clear_error (&error);
}
}
g_free (cwd);
}
else
{
SendMessage (window_handle,
WM_COPYDATA, window_handle, &copydata);
}
return TRUE;
}