gimp r26120 - in trunk: . app app/gui
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26120 - in trunk: . app app/gui
- Date: Fri, 11 Jul 2008 10:31:27 +0000 (UTC)
Author: neo
Date: Fri Jul 11 10:31:27 2008
New Revision: 26120
URL: http://svn.gnome.org/viewvc/gimp?rev=26120&view=rev
Log:
2008-07-11 Sven Neumann <sven gimp org>
* app/unique.c
* app/gui/gui-unique.[ch]: merged code from bug #410439 to
provide
builtin gimp-win-remote functionality for Win32. This is
untested
and most probably doesn't even compile.
Modified:
trunk/ChangeLog
trunk/app/gui/gui-unique.c
trunk/app/gui/gui-unique.h
trunk/app/unique.c
Modified: trunk/app/gui/gui-unique.c
==============================================================================
--- trunk/app/gui/gui-unique.c (original)
+++ trunk/app/gui/gui-unique.c Fri Jul 11 10:31:27 2008
@@ -43,7 +43,10 @@
#endif
#ifdef G_OS_WIN32
-static void gui_unique_win32_init (Gimp *gimp);
+static void gui_unique_win32_init (Gimp *gimp);
+static void gui_unique_win32_exit (void);
+
+static Gimp *unique_gimp = NULL;
#endif
@@ -73,6 +76,7 @@
{
GError *error = NULL;
+ g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (dbus_connection == NULL);
dbus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
@@ -109,10 +113,63 @@
#ifdef G_OS_WIN32
+LRESULT CALLBACK
+gui_unique_win32_message_handler (HWND hWnd,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ switch (uMsg)
+ {
+ case WM_COPYDATA:
+ {
+ COPYDATASTRUCT *copydata = (COPYDATASTRUCT *) lParam;
+
+ if (copydata->cbData > 0)
+ file_open_from_command_line (unique_gimp,
+ copydata->lpData,
+ copydata->dwData != 0);
+ }
+ return TRUE;
+
+ default:
+ return DefWindowProcW (hWnd, uMsg, wParam, lParam);
+ }
+}
+
static void
gui_unique_win32_init (Gimp *gimp)
{
+ WNDCLASSW wc;
+ HWND window_handle;
+
+ g_return_if_fail (GIMP_IS_GIMP (gimp));
+ g_return_if_fail (unique_gimp == NULL);
+
+ unique_gimp = gimp;
+
+ /* register window class for proxy window */
+ memset (&wc, 0, sizeof (wc));
+
+ wc.hInstance = GetModuleHandle (NULL);
+ wc.lpfnWndProc = gui_unique_win32_message_handler;
+ wc.lpszClassName = GIMP_UNIQUE_WIN32_WINDOW_CLASS;
+
+ RegisterClassW (&wc);
+
+ CreateWindowExW (0,
+ GIMP_UNIQUE_WIN32_WINDOW_CLASS,
+ GIMP_UNIQUE_WIN32_WINDOW_NAME,
+ WS_POPUP, 0, 0, 1, 1, NULL, NULL, wc.hInstance, NULL);
+}
+
+static void
+gui_unique_win32_exit (void)
+{
+ g_return_if_fail (GIMP_IS_GIMP (unique_gimp));
+ unique_gimp = NULL;
}
+
#endif /* G_OS_WIN32 */
Modified: trunk/app/gui/gui-unique.h
==============================================================================
--- trunk/app/gui/gui-unique.h (original)
+++ trunk/app/gui/gui-unique.h Fri Jul 11 10:31:27 2008
@@ -19,6 +19,11 @@
#ifndef __GUI_UNIQUE_H__
#define __GUI_UNIQUE_H__
+#ifdef G_OS_WIN32
+#define GIMP_UNIQUE_WIN32_WINDOW_CLASS L"GimpWin32UniqueHandler"
+#define GIMP_UNIQUE_WIN32_WINDOW_NAME L"GimpProxy"
+#endif
+
void gui_unique_init (Gimp *gimp);
void gui_unique_exit (void);
Modified: trunk/app/unique.c
==============================================================================
--- trunk/app/unique.c (original)
+++ trunk/app/unique.c Fri Jul 11 10:31:27 2008
@@ -58,6 +58,35 @@
#endif
}
+static gchar *
+gimp_unique_filename_to_uri (const gchar *filename,
+ const gchar *cwd,
+ GError **error)
+{
+ gchar *uri = NULL;
+
+ if (file_utils_filename_is_uri (filename, error))
+ {
+ uri = g_strdup (filename);
+ }
+ else if (! error)
+ {
+ if (! g_path_is_absolute (filename))
+ {
+ gchar *absolute = g_build_filename (cwd, filename, NULL);
+
+ uri = g_filename_to_uri (absolute, NULL, error);
+
+ g_free (absolute);
+ }
+ else
+ {
+ uri = g_filename_to_uri (filename, NULL, error);
+ }
+ }
+
+ return uri;
+}
#if HAVE_DBUS_GLIB
@@ -86,38 +115,13 @@
if (filenames)
{
const gchar *method = as_new ? "OpenAsNew" : "Open";
- gchar *cwd = NULL;
+ gchar *cwd = g_get_current_dir ();
gint i;
for (i = 0, success = TRUE; filenames[i] && success; i++)
{
- const gchar *filename = filenames[i];
- gchar *uri = NULL;
-
- if (file_utils_filename_is_uri (filename, &error))
- {
- uri = g_strdup (filename);
- }
- else if (! error)
- {
- if (! g_path_is_absolute (filename))
- {
- gchar *absolute;
-
- if (! cwd)
- cwd = g_get_current_dir ();
-
- absolute = g_build_filename (cwd, filename, NULL);
-
- uri = g_filename_to_uri (absolute, NULL, &error);
-
- g_free (absolute);
- }
- else
- {
- uri = g_filename_to_uri (filename, NULL, &error);
- }
- }
+ gchar *uri = gimp_unique_filename_to_uri (filenames[i],
+ cwd, &error);
if (uri)
{
@@ -176,6 +180,44 @@
{
#ifndef GIMP_CONSOLE_COMPILATION
+/* for the proxy window names */
+#include "gui/gui-unique.h"
+
+ HWND window_handle = FindWindowW (GIMP_UNIQUE_WIN32_WINDOW_CLASS,
+ GIMP_UNIQUE_WIN32_WINDOW_NAME);
+
+ if (window_handle)
+ {
+ COPYDATASTRUCT copydata;
+ gchar *cwd = g_get_current_dir ();
+ GError *error = NULL;
+ gint i;
+
+ for (i = 0; filenames[i]; i++)
+ {
+ gchar *uri = gimp_unique_filename_to_uri (filenames[i], cwd, &error);
+
+ 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);
+
+ return TRUE;
+ }
+
#endif
return FALSE
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]