Merge the gtk-printing branch. For more detailed ChangeLog entries, see
2006-04-21 Alexander Larsson <alexl@redhat.com> Merge the gtk-printing branch. For more detailed ChangeLog entries, see the branch. * .cvsignore: * Makefile.am: * configure.in: * docs/tools/widgets.c: * gtk+-unix-print-2.0.pc.in: * gtk/Makefile.am: * gtk/gen-paper-names.c: * gtk/gtk.h: * gtk/gtk.symbols: * gtk/gtkenums.h: * gtk/gtkiconfactory.c: * gtk/gtkmarshalers.list: * gtk/gtkpagesetup.[ch]: * gtk/gtkpagesetupunixdialog.[ch]: * gtk/gtkpapersize.[ch]: * gtk/gtkprint-win32.[ch]: * gtk/gtkprintbackend.[ch]: * gtk/gtkprintcontext.[ch]: * gtk/gtkprinter-private.h: * gtk/gtkprinter.[ch]: * gtk/gtkprinteroption.[ch]: * gtk/gtkprinteroptionset.[ch]: * gtk/gtkprinteroptionwidget.[ch]: * gtk/gtkprintjob.[ch]: * gtk/gtkprintoperation-private.h: * gtk/gtkprintoperation-unix.c: * gtk/gtkprintoperation-win32.c: * gtk/gtkprintoperation.[ch]: * gtk/gtkprintsettings.[ch]: * gtk/gtkprintunixdialog.[ch]: * gtk/paper_names.c: * gtk/paper_names_offsets.c: Platform independent printing API and implementations for unix and windows. * gtk/gtkstock.h: * gtk/stock-icons/24/gtk-orientation-landscape.png: * gtk/stock-icons/24/gtk-orientation-portrait.png: * gtk/stock-icons/24/gtk-orientation-reverse-landscape.png: Add stock icons for page orientation. * modules/Makefile.am: * modules/printbackends/Makefile.am: * modules/printbackends/cups/Makefile.am: * modules/printbackends/cups/gtkcupsutils.[ch]: * modules/printbackends/cups/gtkprintbackendcups.[ch]: * modules/printbackends/cups/gtkprintercups.[ch]: Cups printing backend for unix. * modules/printbackends/lpr/Makefile.am: * modules/printbackends/lpr/gtkprintbackendlpr.[ch]: lpr printing backend for unix. * modules/printbackends/pdf/Makefile.am: * modules/printbackends/pdf/gtkprintbackendpdf.[ch]: print-to-pdf printing backend for unix. * tests/.cvsignore: * tests/Makefile.am: * tests/print-editor.c: Test application for printing. * gdk/gdk.symbols: * gdk/win32/gdkevents-win32.c: * gdk/win32/gdkwin32.h: Add gdk_win32_set_modal_dialog_libgtk_only so that we can pump the mainloop while displaying a win32 common dialog. * gdk/directfb/Makefile.am: Whitespace cleanup.
This commit is contained in:
		 Alexander Larsson
					Alexander Larsson
				
			
				
					committed by
					
						 Alexander Larsson
						Alexander Larsson
					
				
			
			
				
	
			
			
			 Alexander Larsson
						Alexander Larsson
					
				
			
						parent
						
							ea32742b93
						
					
				
				
					commit
					27f746fbd0
				
			
							
								
								
									
										219
									
								
								gtk/gtkprinteroption.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										219
									
								
								gtk/gtkprinteroption.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,219 @@ | ||||
| /* GTK - The GIMP Toolkit | ||||
|  * gtkprinteroption.c: Handling possible settings for a specific printer setting | ||||
|  * Copyright (C) 2006, Red Hat, Inc. | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the | ||||
|  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||||
|  * Boston, MA 02111-1307, USA. | ||||
|  */ | ||||
|  | ||||
| #include "config.h" | ||||
| #include <string.h> | ||||
| #include <gmodule.h> | ||||
|  | ||||
| #include "gtkprinteroption.h" | ||||
| #include "gtkalias.h" | ||||
|  | ||||
| /***************************************** | ||||
|  *            GtkPrinterOption           * | ||||
|  *****************************************/ | ||||
|  | ||||
| enum { | ||||
|   CHANGED, | ||||
|   LAST_SIGNAL | ||||
| }; | ||||
|  | ||||
| static guint signals[LAST_SIGNAL] = { 0 }; | ||||
|  | ||||
| G_DEFINE_TYPE (GtkPrinterOption, gtk_printer_option, G_TYPE_OBJECT) | ||||
|  | ||||
| static void | ||||
| gtk_printer_option_finalize (GObject *object) | ||||
| { | ||||
|   GtkPrinterOption *option = GTK_PRINTER_OPTION (object); | ||||
|   int i; | ||||
|    | ||||
|   g_free (option->name); | ||||
|   g_free (option->display_text); | ||||
|   g_free (option->value); | ||||
|   for (i = 0; i < option->num_choices; i++) | ||||
|     { | ||||
|       g_free (option->choices[i]); | ||||
|       g_free (option->choices_display[i]); | ||||
|     } | ||||
|   g_free (option->choices); | ||||
|   g_free (option->choices_display); | ||||
|   g_free (option->group); | ||||
|    | ||||
|   G_OBJECT_CLASS (gtk_printer_option_parent_class)->finalize (object); | ||||
| } | ||||
|  | ||||
| static void | ||||
| gtk_printer_option_init (GtkPrinterOption *option) | ||||
| { | ||||
|   option->value = g_strdup (""); | ||||
| } | ||||
|  | ||||
| static void | ||||
| gtk_printer_option_class_init (GtkPrinterOptionClass *class) | ||||
| { | ||||
|   GObjectClass *gobject_class = (GObjectClass *)class; | ||||
|  | ||||
|   gobject_class->finalize = gtk_printer_option_finalize; | ||||
|  | ||||
|   signals[CHANGED] = | ||||
|     g_signal_new ("changed", | ||||
| 		  G_TYPE_FROM_CLASS (class), | ||||
| 		  G_SIGNAL_RUN_LAST, | ||||
| 		  G_STRUCT_OFFSET (GtkPrinterOptionClass, changed), | ||||
| 		  NULL, NULL, | ||||
| 		  g_cclosure_marshal_VOID__VOID, | ||||
| 		  G_TYPE_NONE, 0); | ||||
| } | ||||
|  | ||||
| GtkPrinterOption * | ||||
| gtk_printer_option_new (const char *name, const char *display_text, | ||||
| 			       GtkPrinterOptionType type) | ||||
| { | ||||
|   GtkPrinterOption *option; | ||||
|  | ||||
|   option = g_object_new (GTK_TYPE_PRINTER_OPTION, NULL); | ||||
|  | ||||
|   option->name = g_strdup (name); | ||||
|   option->display_text = g_strdup (display_text); | ||||
|   option->type = type; | ||||
|    | ||||
|   return option; | ||||
| } | ||||
|  | ||||
| static void | ||||
| emit_changed (GtkPrinterOption *option) | ||||
| { | ||||
|   g_signal_emit (option, signals[CHANGED], 0); | ||||
| } | ||||
|  | ||||
| void | ||||
| gtk_printer_option_set (GtkPrinterOption *option, | ||||
| 			const char *value) | ||||
| { | ||||
|   if (value == NULL) | ||||
|     value = ""; | ||||
|    | ||||
|   if (strcmp (option->value, value) == 0) | ||||
|     return; | ||||
|  | ||||
|   if (option->type == GTK_PRINTER_OPTION_TYPE_PICKONE && | ||||
|       value != NULL) | ||||
|     { | ||||
|       int i; | ||||
|        | ||||
|       for (i = 0; i < option->num_choices; i++) | ||||
| 	{ | ||||
| 	  if (g_ascii_strcasecmp (value, option->choices[i]) == 0) | ||||
| 	    { | ||||
| 	      value = option->choices[i]; | ||||
| 	      break; | ||||
| 	    } | ||||
| 	} | ||||
|  | ||||
|       if (i == option->num_choices) | ||||
| 	return; /* Not found in availible choices */ | ||||
|     } | ||||
|    | ||||
|   g_free (option->value); | ||||
|   option->value = g_strdup (value); | ||||
|    | ||||
|   emit_changed (option); | ||||
| } | ||||
|  | ||||
| void | ||||
| gtk_printer_option_set_boolean (GtkPrinterOption *option, | ||||
| 				gboolean value) | ||||
| { | ||||
|   gtk_printer_option_set (option, value ? "True" : "False"); | ||||
| } | ||||
|  | ||||
| void | ||||
| gtk_printer_option_set_has_conflict  (GtkPrinterOption *option, | ||||
| 				      gboolean  has_conflict) | ||||
| { | ||||
|   has_conflict = has_conflict != 0; | ||||
|    | ||||
|   if (option->has_conflict == has_conflict) | ||||
|     return; | ||||
|  | ||||
|   option->has_conflict = has_conflict; | ||||
|   emit_changed (option); | ||||
| } | ||||
|  | ||||
| void | ||||
| gtk_printer_option_clear_has_conflict (GtkPrinterOption     *option) | ||||
| { | ||||
|   gtk_printer_option_set_has_conflict  (option, FALSE); | ||||
| } | ||||
|  | ||||
| void | ||||
| gtk_printer_option_allocate_choices (GtkPrinterOption     *option, | ||||
| 				     int num) | ||||
| { | ||||
|   g_free (option->choices); | ||||
|   g_free (option->choices_display); | ||||
|  | ||||
|   option->num_choices = num; | ||||
|   if (num == 0) | ||||
|     { | ||||
|       option->choices = NULL; | ||||
|       option->choices_display = NULL; | ||||
|     } | ||||
|   else | ||||
|     { | ||||
|       option->choices = g_new0 (char *, num); | ||||
|       option->choices_display = g_new0 (char *, num); | ||||
|     } | ||||
| } | ||||
|  | ||||
| void | ||||
| gtk_printer_option_choices_from_array (GtkPrinterOption   *option, | ||||
| 				       int                 num_choices, | ||||
| 				       char               *choices[], | ||||
| 				       char              *choices_display[]) | ||||
| { | ||||
|   int i; | ||||
|    | ||||
|   gtk_printer_option_allocate_choices (option, num_choices); | ||||
|   for (i = 0; i < num_choices; i++) | ||||
|     { | ||||
|       option->choices[i] = g_strdup (choices[i]); | ||||
|       option->choices_display[i] = g_strdup (choices_display[i]); | ||||
|     } | ||||
| } | ||||
|  | ||||
| gboolean | ||||
| gtk_printer_option_has_choice (GtkPrinterOption     *option, | ||||
| 			       const char           *choice) | ||||
| { | ||||
|   int i; | ||||
|    | ||||
|   for (i = 0; i < option->num_choices; i++) | ||||
|     { | ||||
|       if (strcmp (option->choices[i], choice) == 0) | ||||
| 	return TRUE; | ||||
|     } | ||||
|    | ||||
|   return FALSE; | ||||
| } | ||||
|  | ||||
|  | ||||
| #define __GTK_PRINTER_OPTION_C__ | ||||
| #include "gtkaliasdef.c" | ||||
		Reference in New Issue
	
	Block a user