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> 2008-07-13 Aurimas Juška <aurisj@svn.gnome.org>
* app/unique.c (gimp_unique_win32_open): check for NULL pointer to * app/unique.c (gimp_unique_win32_open): check for NULL pointer to

View File

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

View File

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