[gimp/gimp-attributes-wip: 72/73] revert app: gdbus with windows



commit 2c1540bca8b16c2c0906f89ed7e5750c45910786
Author: Hartmut Kuhse <hk_priv gmx de>
Date:   Sat Nov 12 14:02:02 2016 +0100

    revert app: gdbus with windows

 app/gui/gui-unique.c |  286 +++++++++++++++++++++++++-------------------------
 app/unique.c         |    3 +-
 2 files changed, 144 insertions(+), 145 deletions(-)
---
diff --git a/app/gui/gui-unique.c b/app/gui/gui-unique.c
index 5ac5c04..7eb9517 100644
--- a/app/gui/gui-unique.c
+++ b/app/gui/gui-unique.c
@@ -64,7 +64,7 @@ static void gui_unique_quartz_exit (void);
 static Gimp                   *unique_gimp   = NULL;
 static GimpAppleEventHandler  *event_handler = NULL;
 
-#endif
+#else
 
 static void  gui_dbus_service_init (Gimp *gimp);
 static void  gui_dbus_service_exit (void);
@@ -72,169 +72,169 @@ static void  gui_dbus_service_exit (void);
 static GDBusObjectManagerServer *dbus_manager = NULL;
 static guint                     dbus_name_id = 0;
 
-//#endif
+#endif
 
 
 void
 gui_unique_init (Gimp *gimp)
 {
 #ifdef G_OS_WIN32
-//  gui_unique_win32_init (gimp);
+  gui_unique_win32_init (gimp);
 #elif defined (GDK_WINDOWING_QUARTZ)
   gui_unique_quartz_init (gimp);
-#endif
+#else
   gui_dbus_service_init (gimp);
-//#endif
+#endif
 }
 
 void
 gui_unique_exit (void)
 {
 #ifdef G_OS_WIN32
-//  gui_unique_win32_exit ();
+  gui_unique_win32_exit ();
 #elif defined (GDK_WINDOWING_QUARTZ)
   gui_unique_quartz_exit ();
-#endif
+#else
   gui_dbus_service_exit ();
-//#endif
+#endif
 }
 
 
 #ifdef G_OS_WIN32
 
-//typedef struct
-//{
-//  GFile    *file;
-//  gboolean  as_new;
-//} IdleOpenData;
-//
-//static IdleOpenData *
-//idle_open_data_new (GFile    *file,
-//                    gboolean  as_new)
-//{
-//  IdleOpenData *data = g_slice_new0 (IdleOpenData);
-//
-//  data->file   = g_object_ref (file);
-//  data->as_new = as_new;
-//
-//  return data;
-//}
-//
-//static void
-//idle_open_data_free (IdleOpenData *data)
-//{
-//  g_object_unref (data->file);
-//  g_slice_free (IdleOpenData, data);
-//}
-//
-//static gboolean
-//gui_unique_win32_idle_open (IdleOpenData *data)
-//{
-//  /*  We want to be called again later in case that GIMP is not fully
-//   *  started yet.
-//   */
-//  if (! gimp_is_restored (unique_gimp))
-//    return TRUE;
-//
-//  if (data->file)
-//    {
-//      file_open_from_command_line (unique_gimp, data->file,
-//                                   data->as_new, NULL, 0);
-//    }
-//  else
-//    {
-//      /*  raise the first display  */
-//      GimpObject *display;
-//
-//      display = gimp_container_get_first_child (unique_gimp->displays);
-//
-//      gimp_display_shell_present (gimp_display_get_shell (GIMP_DISPLAY (display)));
-//    }
-//
-//  return FALSE;
-//}
-//
-//static LRESULT CALLBACK
-//gui_unique_win32_message_handler (HWND   hWnd,
-//                                  UINT   uMsg,
-//                                  WPARAM wParam,
-//                                  LPARAM lParam)
-//{
-//  switch (uMsg)
-//    {
-//    case WM_COPYDATA:
-//      if (unique_gimp)
-//        {
-//          COPYDATASTRUCT *copydata = (COPYDATASTRUCT *) lParam;
-//
-//          if (copydata->cbData > 0)
-//            {
-//              GSource        *source;
-//              GClosure       *closure;
-//              GFile          *file;
-//              IdleOpenData   *data;
-//
-//              file = g_file_new_for_uri (copydata->lpData);
-//
-//              data = idle_open_data_new (file,
-//                                         copydata->dwData != 0);
-//
-//              g_object_unref (file);
-//
-//              closure = g_cclosure_new (G_CALLBACK (gui_unique_win32_idle_open),
-//                                        data,
-//                                        (GClosureNotify) idle_open_data_free);
-//
-//              g_object_watch_closure (G_OBJECT (unique_gimp), closure);
-//
-//              source = g_idle_source_new ();
-//              g_source_set_priority (source, G_PRIORITY_LOW);
-//              g_source_set_closure (source, closure);
-//              g_source_attach (source, NULL);
-//              g_source_unref (source);
-//            }
-//        }
-//      return TRUE;
-//
-//    default:
-//      return DefWindowProcW (hWnd, uMsg, wParam, lParam);
-//    }
-//}
-//
-//static void
-//gui_unique_win32_init (Gimp *gimp)
-//{
-//  WNDCLASSW wc;
-//
-//  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);
-//
-//  proxy_window = 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;
-//
-//  DestroyWindow (proxy_window);
-//}
+typedef struct
+{
+  GFile    *file;
+  gboolean  as_new;
+} IdleOpenData;
+
+static IdleOpenData *
+idle_open_data_new (GFile    *file,
+                    gboolean  as_new)
+{
+  IdleOpenData *data = g_slice_new0 (IdleOpenData);
+
+  data->file   = g_object_ref (file);
+  data->as_new = as_new;
+
+  return data;
+}
+
+static void
+idle_open_data_free (IdleOpenData *data)
+{
+  g_object_unref (data->file);
+  g_slice_free (IdleOpenData, data);
+}
+
+static gboolean
+gui_unique_win32_idle_open (IdleOpenData *data)
+{
+  /*  We want to be called again later in case that GIMP is not fully
+   *  started yet.
+   */
+  if (! gimp_is_restored (unique_gimp))
+    return TRUE;
+
+  if (data->file)
+    {
+      file_open_from_command_line (unique_gimp, data->file,
+                                   data->as_new, NULL, 0);
+    }
+  else
+    {
+      /*  raise the first display  */
+      GimpObject *display;
+
+      display = gimp_container_get_first_child (unique_gimp->displays);
+
+      gimp_display_shell_present (gimp_display_get_shell (GIMP_DISPLAY (display)));
+    }
+
+  return FALSE;
+}
+
+static LRESULT CALLBACK
+gui_unique_win32_message_handler (HWND   hWnd,
+                                  UINT   uMsg,
+                                  WPARAM wParam,
+                                  LPARAM lParam)
+{
+  switch (uMsg)
+    {
+    case WM_COPYDATA:
+      if (unique_gimp)
+        {
+          COPYDATASTRUCT *copydata = (COPYDATASTRUCT *) lParam;
+
+          if (copydata->cbData > 0)
+            {
+              GSource        *source;
+              GClosure       *closure;
+              GFile          *file;
+              IdleOpenData   *data;
+
+              file = g_file_new_for_uri (copydata->lpData);
+
+              data = idle_open_data_new (file,
+                                         copydata->dwData != 0);
+
+              g_object_unref (file);
+
+              closure = g_cclosure_new (G_CALLBACK (gui_unique_win32_idle_open),
+                                        data,
+                                        (GClosureNotify) idle_open_data_free);
+
+              g_object_watch_closure (G_OBJECT (unique_gimp), closure);
+
+              source = g_idle_source_new ();
+              g_source_set_priority (source, G_PRIORITY_LOW);
+              g_source_set_closure (source, closure);
+              g_source_attach (source, NULL);
+              g_source_unref (source);
+            }
+        }
+      return TRUE;
+
+    default:
+      return DefWindowProcW (hWnd, uMsg, wParam, lParam);
+    }
+}
+
+static void
+gui_unique_win32_init (Gimp *gimp)
+{
+  WNDCLASSW wc;
+
+  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);
+
+  proxy_window = 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;
+
+  DestroyWindow (proxy_window);
+}
 
 #elif defined (GDK_WINDOWING_QUARTZ)
 
@@ -364,7 +364,7 @@ gui_unique_quartz_exit (void)
   event_handler = NULL;
 }
 
-#endif
+#else
 
 static void
 gui_dbus_bus_acquired (GDBusConnection *connection,
@@ -426,4 +426,4 @@ gui_dbus_service_exit (void)
   g_object_unref (dbus_manager);
 }
 
-//#endif
+#endif
diff --git a/app/unique.c b/app/unique.c
index 1f58942..8e0f477 100644
--- a/app/unique.c
+++ b/app/unique.c
@@ -47,8 +47,7 @@ gimp_unique_open (const gchar **filenames,
                   gboolean      as_new)
 {
 #ifdef G_OS_WIN32
-//  return gimp_unique_win32_open (filenames, as_new);
-  return gimp_unique_dbus_open (filenames, as_new);
+  return gimp_unique_win32_open (filenames, as_new);
 #else
   return gimp_unique_dbus_open (filenames, as_new);
 #endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]