diff --git a/ChangeLog b/ChangeLog index 164335f550..86ec5bd199 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-07-13 Sven Neumann + + * 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 * app/unique.c (gimp_unique_win32_open): check for NULL pointer to diff --git a/app/gui/gui-unique.c b/app/gui/gui-unique.c index 5eaf81212f..cd4ff3ae74 100644 --- a/app/gui/gui-unique.c +++ b/app/gui/gui-unique.c @@ -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 (""); + + 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: diff --git a/app/unique.c b/app/unique.c index ced745d172..1938d681b9 100644 --- a/app/unique.c +++ b/app/unique.c @@ -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, ©data); - } - 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, ©data); + } + 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, ©data); + } return TRUE; }