summaryrefslogtreecommitdiff
path: root/gtk/gtkprint-win32.c
diff options
context:
space:
mode:
authorTor Lillqvist <tml@novell.com>2008-08-02 09:27:47 +0000
committerTor Lillqvist <tml@src.gnome.org>2008-08-02 09:27:47 +0000
commit8ce17cf990f996c02fd88d89abbf8d9ff97dbe9f (patch)
tree9a36fb004dc3aa14981f10cf79be03d73043a658 /gtk/gtkprint-win32.c
parent5fde2609d787d2d66e8bbb0a1771deda1a8ce150 (diff)
downloadgtk+-8ce17cf990f996c02fd88d89abbf8d9ff97dbe9f.tar.gz
Bug 339699 - implement gtk_print_operation_set_show_dialog for Windows
2008-08-02 Tor Lillqvist <tml@novell.com> Bug 339699 - implement gtk_print_operation_set_show_dialog for Windows * gtk/gtkprint-win32.c * gtk/gtkprint-win32.h * gtk/gtkprintoperation-win32.c: Patch by ecyrbe@gmail.com. svn path=/trunk/; revision=20942
Diffstat (limited to 'gtk/gtkprint-win32.c')
-rw-r--r--gtk/gtkprint-win32.c49
1 files changed, 46 insertions, 3 deletions
diff --git a/gtk/gtkprint-win32.c b/gtk/gtkprint-win32.c
index 69b508a6e4..d871961dda 100644
--- a/gtk/gtkprint-win32.c
+++ b/gtk/gtkprint-win32.c
@@ -100,10 +100,53 @@ gtk_print_win32_devnames_to_win32 (const GtkPrintWin32Devnames *devnames)
}
HGLOBAL
-gtk_print_win32_devnames_from_printer_name (const char *printer)
+gtk_print_win32_devnames_to_win32_from_printer_name (const char *printer_name)
{
- const GtkPrintWin32Devnames devnames = { "", (char *)printer, "", 0 };
- return gtk_print_win32_devnames_to_win32 (&devnames);
+ HGLOBAL global;
+ GtkPrintWin32Devnames *devnames;
+ devnames = gtk_print_win32_devnames_from_printer_name(printer_name);
+ if(devnames)
+ {
+ global = gtk_print_win32_devnames_to_win32 (devnames);
+ gtk_print_win32_devnames_free(devnames);
+ }
+ else
+ global = NULL;
+ return global;
+}
+
+/**
+ used to get printer device information from a printer name
+ since this can fail, because the user have no right to read printer properties, this function can return NULL
+*/
+GtkPrintWin32Devnames *
+gtk_print_win32_devnames_from_printer_name (const char *printer_name)
+{
+ HANDLE hprinter;
+ gunichar2* win32_printer_name;
+ GtkPrintWin32Devnames *devnames;
+ win32_printer_name = g_utf8_to_utf16 (printer_name, -1, NULL, NULL, NULL);
+ if(OpenPrinterW(win32_printer_name, &hprinter, NULL))
+ {
+ DWORD needed;
+ PRINTER_INFO_2W* printer_info;
+ GetPrinterW(hprinter, 2, NULL, 0,&needed);
+ printer_info = (PRINTER_INFO_2W*)g_malloc((gsize)needed);
+ GetPrinterW(hprinter, 2, (LPBYTE)printer_info,needed,&needed);
+ devnames = g_new (GtkPrintWin32Devnames, 1);
+ devnames->driver = g_utf16_to_utf8(printer_info->pDriverName,-1,NULL,NULL,NULL);
+ devnames->device = g_strdup(printer_name);
+ devnames->output = g_utf16_to_utf8(printer_info->pPortName,-1,NULL,NULL,NULL);
+ devnames->flags = 0;
+ ClosePrinter(hprinter);
+ g_free(printer_info);
+ }else
+ {
+ // could not open printer
+ devnames = NULL;
+ }
+ g_free(win32_printer_name);
+ return devnames;
}