diff options
author | Tor Lillqvist <tml@novell.com> | 2008-08-02 09:31:01 +0000 |
---|---|---|
committer | Tor Lillqvist <tml@src.gnome.org> | 2008-08-02 09:31:01 +0000 |
commit | c364ffa34036610664c3ba6089009f9c86c1e8fb (patch) | |
tree | 3615e8f57cc4494a2e67a0baae9b595291952639 /gtk/gtkprint-win32.c | |
parent | 8ce17cf990f996c02fd88d89abbf8d9ff97dbe9f (diff) | |
download | gtk+-c364ffa34036610664c3ba6089009f9c86c1e8fb.tar.gz |
gtk/gtkprint-win32.c gtk/gtkprint-win32.h Cosmetic fixups after patch
2008-08-02 Tor Lillqvist <tml@novell.com>
* gtk/gtkprint-win32.c
* gtk/gtkprint-win32.h
* gtk/gtkprintoperation-win32.c: Cosmetic fixups after patch
below.
svn path=/trunk/; revision=20943
Diffstat (limited to 'gtk/gtkprint-win32.c')
-rw-r--r-- | gtk/gtkprint-win32.c | 65 |
1 files changed, 36 insertions, 29 deletions
diff --git a/gtk/gtkprint-win32.c b/gtk/gtkprint-win32.c index d871961dda..b7faae20f4 100644 --- a/gtk/gtkprint-win32.c +++ b/gtk/gtkprint-win32.c @@ -104,48 +104,55 @@ gtk_print_win32_devnames_to_win32_from_printer_name (const char *printer_name) { 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); - } + 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 -*/ +/* + * Used to get printer device information from a printer name. This + * can fail if the user has no right to read printer properties, so + * 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); + 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; } |