Add gdk_win32_set_modal_dialog_libgtk_only that we need for handling the

2006-04-11  Alexander Larsson  <alexl@redhat.com>

	* gdk/gdk.symbols:
	* gdk/win32/gdkevents-win32.c:
	* gdk/win32/gdkwin32.h:
	Add gdk_win32_set_modal_dialog_libgtk_only that we
	need for handling the mainloop in the print dialogs.

	* gtk/gtkprintoperation-win32.c:
	Pump the gtk+ mainloop when needed in the print dialogs.
	This means gtk+ windows will redraw while the print dialogs
	are up.
This commit is contained in:
Alexander Larsson
2006-04-11 16:06:06 +00:00
committed by Alexander Larsson
parent 8946d1e768
commit bc507783e0
7 changed files with 210 additions and 7 deletions

View File

@@ -1,3 +1,16 @@
2006-04-11 Alexander Larsson <alexl@redhat.com>
* gdk/gdk.symbols:
* gdk/win32/gdkevents-win32.c:
* gdk/win32/gdkwin32.h:
Add gdk_win32_set_modal_dialog_libgtk_only that we
need for handling the mainloop in the print dialogs.
* gtk/gtkprintoperation-win32.c:
Pump the gtk+ mainloop when needed in the print dialogs.
This means gtk+ windows will redraw while the print dialogs
are up.
2006-04-10 Alexander Larsson <alexl@redhat.com>
* gtk/gtkprintoperation-win32.c:

View File

@@ -1,3 +1,16 @@
2006-04-11 Alexander Larsson <alexl@redhat.com>
* gdk/gdk.symbols:
* gdk/win32/gdkevents-win32.c:
* gdk/win32/gdkwin32.h:
Add gdk_win32_set_modal_dialog_libgtk_only that we
need for handling the mainloop in the print dialogs.
* gtk/gtkprintoperation-win32.c:
Pump the gtk+ mainloop when needed in the print dialogs.
This means gtk+ windows will redraw while the print dialogs
are up.
2006-04-10 Alexander Larsson <alexl@redhat.com>
* gtk/gtkprintoperation-win32.c:

View File

@@ -18,9 +18,6 @@ PDF backend:
* Change to using a GtkFileChooserEntry to get file names when we move to
GTK. It is a private object in GTK right now.
Win32:
* Use threads for the dialog, to allow repaints of other windows while they are up
Cups/Unix print dialog:
* Use themed icons for the collate/reverse?
* Add custom translations for a lot of standard PPD options
@@ -38,6 +35,7 @@ General:
* general print to file module (ps+pdf)
* use real gtk+ stock icon for print to pdf icon
* GtkPrinter shouldn't ref backend since the backend refs the printers
* Keep ref on print operation during run()
Print dialog wishlist:
* Don't select default for a short while, so that we can avoid flashing if the selected printer appears

View File

@@ -1109,6 +1109,12 @@ gdk_win32_drawable_get_handle
#endif
#endif
#if IN_HEADER(__GDK_WIN32_H__)
#if IN_FILE(__GDK_EVENTS_WIN32_C__)
gdk_win32_set_modal_dialog_libgtk_only
#endif
#endif
#if IN_HEADER(__GDK_WIN32_H__)
#if IN_FILE(__GDK_GC_WIN32_C__)
gdk_win32_hdc_get

View File

@@ -144,6 +144,9 @@ static gint current_root_x, current_root_y;
static UINT msh_mousewheel;
static UINT client_message;
static UINT got_gdk_events_message;
static HWND modal_win32_dialog = NULL;
#ifdef HAVE_DIMM_H
static IActiveIMMApp *active_imm_app = NULL;
static IActiveIMMMessagePumpOwner *active_imm_msgpump_owner = NULL;
@@ -281,6 +284,9 @@ inner_window_procedure (HWND hwnd,
/* If gdk_event_translate() returns TRUE, we return ret_val from
* the window procedure.
*/
if (modal_win32_dialog)
PostMessage (modal_win32_dialog, got_gdk_events_message,
(WPARAM) 1, 0);
return ret_val;
}
else
@@ -379,6 +385,7 @@ _gdk_events_init (void)
msh_mousewheel = RegisterWindowMessage ("MSWHEEL_ROLLMSG");
client_message = RegisterWindowMessage ("GDK_WIN32_CLIENT_MESSAGE");
got_gdk_events_message = RegisterWindowMessage ("GDK_WIN32_GOT_EVENTS");
#if 0
/* Check if we have some input locale identifier loaded that uses a
@@ -463,7 +470,8 @@ gdk_events_pending (void)
{
MSG msg;
return (_gdk_event_queue_find_first (_gdk_display) ||
PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE));
(modal_win32_dialog == NULL &&
PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)));
}
GdkEvent*
@@ -3516,6 +3524,9 @@ _gdk_events_queue (GdkDisplay *display)
{
MSG msg;
if (modal_win32_dialog != NULL)
return;
while (!_gdk_event_queue_find_first (display) &&
PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
{
@@ -3536,7 +3547,8 @@ gdk_event_prepare (GSource *source,
*timeout = -1;
retval = (_gdk_event_queue_find_first (_gdk_display) != NULL ||
PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE));
(modal_win32_dialog == NULL &&
PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)));
GDK_THREADS_LEAVE ();
@@ -3553,7 +3565,8 @@ gdk_event_check (GSource *source)
if (event_poll_fd.revents & G_IO_IN)
retval = (_gdk_event_queue_find_first (_gdk_display) != NULL ||
PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE));
(modal_win32_dialog == NULL &&
PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)));
else
retval = FALSE;
@@ -3587,6 +3600,12 @@ gdk_event_dispatch (GSource *source,
return TRUE;
}
void
gdk_win32_set_modal_dialog_libgtk_only (HWND window)
{
modal_win32_dialog = window;
}
static void
check_for_too_much_data (GdkEvent *event)
{

View File

@@ -87,6 +87,7 @@ void gdk_win32_selection_add_targets (GdkWindow *owner,
/* For internal GTK use only */
GdkPixbuf * gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon);
HICON gdk_win32_pixbuf_to_hicon_libgtk_only (GdkPixbuf *pixbuf);
void gdk_win32_set_modal_dialog_libgtk_only (HWND window);
G_END_DECLS

View File

@@ -23,6 +23,7 @@
#define WINVER _WIN32_WINNT
#endif
#define COBJMACROS
#include "config.h"
#include <math.h>
#include <stdlib.h>
@@ -56,6 +57,39 @@ typedef struct {
static void win32_poll_status (GtkPrintOperation *op);
static const GUID myIID_IPrintDialogCallback = {0x5852a2c3,0x6530,0x11d1,{0xb6,0xa3,0x0,0x0,0xf8,0x75,0x7b,0xf9}};
#undef INTERFACE
#define INTERFACE IPrintDialogCallback
DECLARE_INTERFACE_ (IPrintDialogCallback, IUnknown)
{
STDMETHOD (QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
STDMETHOD_ (ULONG, AddRef)(THIS) PURE;
STDMETHOD_ (ULONG, Release)(THIS) PURE;
STDMETHOD (InitDone)(THIS) PURE;
STDMETHOD (SelectionChange)(THIS) PURE;
STDMETHOD (HandleMessage)(THIS_ HWND,UINT,WPARAM,LPARAM,LRESULT*) PURE;
};
static UINT got_gdk_events_message;
UINT_PTR CALLBACK
run_mainloop_hook (HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
if (uiMsg == WM_INITDIALOG)
{
gdk_win32_set_modal_dialog_libgtk_only (hdlg);
while (gtk_events_pending ())
gtk_main_iteration ();
}
else if (uiMsg == got_gdk_events_message)
{
while (gtk_events_pending ())
gtk_main_iteration ();
return 1;
}
return 0;
}
static GtkPageOrientation
orientation_from_win32 (short orientation)
@@ -1120,6 +1154,114 @@ dialog_from_print_settings (GtkPrintOperation *op,
op->priv->default_page_setup);
}
typedef struct {
IPrintDialogCallback iPrintDialogCallback;
gboolean set_hwnd;
int ref_count;
} PrintDialogCallback;
static ULONG STDMETHODCALLTYPE
iprintdialogcallback_addref (IPrintDialogCallback *This)
{
PrintDialogCallback *callback = (PrintDialogCallback *)This;
return ++callback->ref_count;
}
static ULONG STDMETHODCALLTYPE
iprintdialogcallback_release (IPrintDialogCallback *This)
{
PrintDialogCallback *callback = (PrintDialogCallback *)This;
int ref_count = --callback->ref_count;
if (ref_count == 0)
g_free (This);
return ref_count;
}
static HRESULT STDMETHODCALLTYPE
iprintdialogcallback_queryinterface (IPrintDialogCallback *This,
REFIID riid,
LPVOID *ppvObject)
{
if (IsEqualIID (riid, &IID_IUnknown) ||
IsEqualIID (riid, &myIID_IPrintDialogCallback))
{
*ppvObject = This;
IUnknown_AddRef ((IUnknown *)This);
return NOERROR;
}
else
{
*ppvObject = NULL;
return E_NOINTERFACE;
}
}
static HRESULT STDMETHODCALLTYPE
iprintdialogcallback_initdone (IPrintDialogCallback *This)
{
return S_FALSE;
}
static HRESULT STDMETHODCALLTYPE
iprintdialogcallback_selectionchange (IPrintDialogCallback *This)
{
return S_FALSE;
}
static HRESULT STDMETHODCALLTYPE
iprintdialogcallback_handlemessage (IPrintDialogCallback *This,
HWND hDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam,
LRESULT *pResult)
{
PrintDialogCallback *callback = (PrintDialogCallback *)This;
if (!callback->set_hwnd)
{
gdk_win32_set_modal_dialog_libgtk_only (hDlg);
callback->set_hwnd = TRUE;
while (gtk_events_pending ())
gtk_main_iteration ();
}
else if (uMsg == got_gdk_events_message)
{
while (gtk_events_pending ())
gtk_main_iteration ();
*pResult = TRUE;
return S_OK;
}
*pResult = 0;
return S_FALSE;
}
static IPrintDialogCallbackVtbl ipdc_vtbl = {
iprintdialogcallback_queryinterface,
iprintdialogcallback_addref,
iprintdialogcallback_release,
iprintdialogcallback_initdone,
iprintdialogcallback_selectionchange,
iprintdialogcallback_handlemessage
};
static IPrintDialogCallback *
print_callback_new (void)
{
PrintDialogCallback *callback;
callback = g_new0 (PrintDialogCallback, 1);
callback->iPrintDialogCallback.lpVtbl = &ipdc_vtbl;
callback->ref_count = 1;
callback->set_hwnd = FALSE;
return &callback->iPrintDialogCallback;
}
GtkPrintOperationResult
_gtk_print_operation_platform_backend_run_dialog (GtkPrintOperation *op,
GtkWindow *parent,
@@ -1133,6 +1275,7 @@ _gtk_print_operation_platform_backend_run_dialog (GtkPrintOperation *op,
GtkWidget *invisible = NULL;
GtkPrintOperationResult result;
GtkPrintOperationWin32 *op_win32;
IPrintDialogCallback *callback;
*do_print = FALSE;
@@ -1197,8 +1340,13 @@ _gtk_print_operation_platform_backend_run_dialog (GtkPrintOperation *op,
dialog_from_print_settings (op, printdlgex);
/* TODO: We should do this in a thread to avoid blocking the mainloop */
callback = print_callback_new ();
printdlgex->lpCallback = (IUnknown *)callback;
got_gdk_events_message = RegisterWindowMessage ("GDK_WIN32_GOT_EVENTS");
hResult = PrintDlgExW(printdlgex);
IUnknown_Release ((IUnknown *)callback);
gdk_win32_set_modal_dialog_libgtk_only (NULL);
if (hResult != S_OK)
{
@@ -1390,8 +1538,13 @@ gtk_print_run_page_setup_dialog (GtkWindow *parent,
floor (gtk_page_setup_get_top_margin (page_setup, unit) * scale + 0.5);
pagesetupdlg->rtMargin.bottom =
floor (gtk_page_setup_get_bottom_margin (page_setup, unit) * scale + 0.5);
pagesetupdlg->Flags |= PSD_ENABLEPAGESETUPHOOK;
pagesetupdlg->lpfnPageSetupHook = run_mainloop_hook;
got_gdk_events_message = RegisterWindowMessage ("GDK_WIN32_GOT_EVENTS");
res = PageSetupDlgW (pagesetupdlg);
gdk_win32_set_modal_dialog_libgtk_only (NULL);
if (res)
{