Add GTK_PRINTER_OPTION_TYPE_ALTERNATIVE which is semantically the same as
2006-06-17 Matthias Clasen <mclasen@redhat.com> * gtk/gtkprinteroption.h: * gtk/gtkprinteroption.c: Add GTK_PRINTER_OPTION_TYPE_ALTERNATIVE which is semantically the same as PICKONE, but is intended to show all options all the time. * gtk/gtkprinteroptionwidget.c: Implement ALTERNATIVE as radio group.
This commit is contained in:
		 Matthias Clasen
					Matthias Clasen
				
			
				
					committed by
					
						 Matthias Clasen
						Matthias Clasen
					
				
			
			
				
	
			
			
			 Matthias Clasen
						Matthias Clasen
					
				
			
						parent
						
							505c6149cc
						
					
				
				
					commit
					320660fb81
				
			
							
								
								
									
										10
									
								
								ChangeLog
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								ChangeLog
									
									
									
									
									
								
							| @ -1,3 +1,13 @@ | ||||
| 2006-06-17  Matthias Clasen  <mclasen@redhat.com> | ||||
|  | ||||
| 	* gtk/gtkprinteroption.h:  | ||||
| 	* gtk/gtkprinteroption.c: Add GTK_PRINTER_OPTION_TYPE_ALTERNATIVE | ||||
| 	which is semantically the same as PICKONE, but is intended to  | ||||
| 	show all options all the time. | ||||
| 	 | ||||
| 	* gtk/gtkprinteroptionwidget.c: Implement ALTERNATIVE as radio | ||||
| 	group. | ||||
|  | ||||
| 2006-06-16  Matthias Clasen  <mclasen@redhat.com> | ||||
|  | ||||
| 	* modules/printbackends/cups/gtkprintbackendcups.c: | ||||
|  | ||||
| @ -1,3 +1,13 @@ | ||||
| 2006-06-17  Matthias Clasen  <mclasen@redhat.com> | ||||
|  | ||||
| 	* gtk/gtkprinteroption.h:  | ||||
| 	* gtk/gtkprinteroption.c: Add GTK_PRINTER_OPTION_TYPE_ALTERNATIVE | ||||
| 	which is semantically the same as PICKONE, but is intended to  | ||||
| 	show all options all the time. | ||||
| 	 | ||||
| 	* gtk/gtkprinteroptionwidget.c: Implement ALTERNATIVE as radio | ||||
| 	group. | ||||
|  | ||||
| 2006-06-16  Matthias Clasen  <mclasen@redhat.com> | ||||
|  | ||||
| 	* modules/printbackends/cups/gtkprintbackendcups.c: | ||||
|  | ||||
| @ -113,7 +113,8 @@ gtk_printer_option_set (GtkPrinterOption *option, | ||||
|   if (strcmp (option->value, value) == 0) | ||||
|     return; | ||||
|  | ||||
|   if (option->type == GTK_PRINTER_OPTION_TYPE_PICKONE && | ||||
|   if ((option->type == GTK_PRINTER_OPTION_TYPE_PICKONE || | ||||
|        option->type == GTK_PRINTER_OPTION_TYPE_ALTERNATIVE) && | ||||
|       value != NULL) | ||||
|     { | ||||
|       int i; | ||||
|  | ||||
| @ -46,6 +46,7 @@ typedef struct _GtkPrinterOptionClass  GtkPrinterOptionClass; | ||||
| typedef enum { | ||||
|   GTK_PRINTER_OPTION_TYPE_BOOLEAN, | ||||
|   GTK_PRINTER_OPTION_TYPE_PICKONE, | ||||
|   GTK_PRINTER_OPTION_TYPE_ALTERNATIVE, | ||||
|   GTK_PRINTER_OPTION_TYPE_STRING, | ||||
|   GTK_PRINTER_OPTION_TYPE_FILESAVE | ||||
| } GtkPrinterOptionType; | ||||
|  | ||||
| @ -32,6 +32,7 @@ | ||||
| #include "gtkimage.h" | ||||
| #include "gtklabel.h" | ||||
| #include "gtkliststore.h" | ||||
| #include "gtkradiobutton.h" | ||||
| #include "gtkstock.h" | ||||
| #include "gtktable.h" | ||||
| #include "gtktogglebutton.h" | ||||
| @ -60,6 +61,7 @@ struct GtkPrinterOptionWidgetPrivate | ||||
|   GtkWidget *image; | ||||
|   GtkWidget *label; | ||||
|   GtkWidget *filechooser; | ||||
|   GtkWidget *box; | ||||
| }; | ||||
|  | ||||
| enum { | ||||
| @ -471,6 +473,61 @@ entry_changed_cb (GtkWidget *entry, | ||||
| } | ||||
|  | ||||
|  | ||||
| static void | ||||
| radio_changed_cb (GtkWidget              *button, | ||||
| 		  GtkPrinterOptionWidget *widget) | ||||
| { | ||||
|   GtkPrinterOptionWidgetPrivate *priv = widget->priv; | ||||
|   char *value; | ||||
|    | ||||
|   g_signal_handler_block (priv->source, priv->source_changed_handler); | ||||
|   value = g_object_get_data (G_OBJECT (button), "value"); | ||||
|   if (value) | ||||
|     gtk_printer_option_set (priv->source, value); | ||||
|   g_free (value); | ||||
|   g_signal_handler_unblock (priv->source, priv->source_changed_handler); | ||||
|   emit_changed (widget); | ||||
| } | ||||
|  | ||||
| static void | ||||
| alternative_set (GtkWidget   *box, | ||||
| 		 const gchar *value) | ||||
| { | ||||
|   GList *children, *l; | ||||
|  | ||||
|   children = gtk_container_get_children (GTK_CONTAINER (box)); | ||||
|  | ||||
|   for (l = children; l != NULL; l = l->next) | ||||
|     { | ||||
|       char *v = g_object_get_data (G_OBJECT (l->data), "value"); | ||||
|        | ||||
|       if (strcmp (value, v) == 0) | ||||
| 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (l->data), TRUE); | ||||
|     } | ||||
|  | ||||
|   g_list_free (children); | ||||
| } | ||||
|  | ||||
| static GSList * | ||||
| alternative_append (GtkWidget   *box, | ||||
| 		    const gchar *label, | ||||
|                     const gchar *value, | ||||
| 		    GtkPrinterOptionWidget *widget, | ||||
| 		    GSList      *group) | ||||
| { | ||||
|   GtkWidget *button; | ||||
|  | ||||
|   button = gtk_radio_button_new_with_label (group, label); | ||||
|   gtk_widget_show (button); | ||||
|   gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0); | ||||
|  | ||||
|   g_object_set_data (G_OBJECT (button), "value", (gpointer)value); | ||||
|   g_signal_connect (button, "toggled",  | ||||
| 		    G_CALLBACK (radio_changed_cb), widget); | ||||
|  | ||||
|   return gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)); | ||||
| } | ||||
|  | ||||
| static void | ||||
| construct_widgets (GtkPrinterOptionWidget *widget) | ||||
| { | ||||
| @ -478,6 +535,7 @@ construct_widgets (GtkPrinterOptionWidget *widget) | ||||
|   GtkPrinterOption *source; | ||||
|   char *text; | ||||
|   int i; | ||||
|   GSList *group; | ||||
|  | ||||
|   source = priv->source; | ||||
|    | ||||
| @ -500,6 +558,7 @@ construct_widgets (GtkPrinterOptionWidget *widget) | ||||
|       gtk_widget_show (priv->check); | ||||
|       gtk_box_pack_start (GTK_BOX (widget), priv->check, TRUE, TRUE, 0); | ||||
|       break; | ||||
|  | ||||
|     case GTK_PRINTER_OPTION_TYPE_PICKONE: | ||||
|       priv->combo = combo_box_new (); | ||||
|       for (i = 0; i < source->num_choices; i++) | ||||
| @ -515,6 +574,28 @@ construct_widgets (GtkPrinterOptionWidget *widget) | ||||
|       g_free (text); | ||||
|       gtk_widget_show (priv->label); | ||||
|       break; | ||||
|  | ||||
|     case GTK_PRINTER_OPTION_TYPE_ALTERNATIVE: | ||||
|       group = NULL; | ||||
|       priv->box = gtk_hbox_new (FALSE, 12); | ||||
|       gtk_widget_show (priv->box); | ||||
|       gtk_box_pack_start (GTK_BOX (widget), priv->box, TRUE, TRUE, 0); | ||||
|       for (i = 0; i < source->num_choices; i++) | ||||
| 	group = alternative_append (priv->box, | ||||
| 				    source->choices_display[i], | ||||
| 				    source->choices[i], | ||||
| 				    widget, | ||||
| 				    group); | ||||
|  | ||||
|       if (source->display_text) | ||||
| 	{ | ||||
| 	  text = g_strdup_printf ("%s:", source->display_text); | ||||
| 	  priv->label = gtk_label_new_with_mnemonic (text); | ||||
| 	  g_free (text); | ||||
| 	  gtk_widget_show (priv->label); | ||||
| 	} | ||||
|       break; | ||||
|  | ||||
|     case GTK_PRINTER_OPTION_TYPE_STRING: | ||||
|       priv->entry = gtk_entry_new (); | ||||
|       gtk_widget_show (priv->entry); | ||||
| @ -606,6 +687,9 @@ update_widgets (GtkPrinterOptionWidget *widget) | ||||
|     case GTK_PRINTER_OPTION_TYPE_PICKONE: | ||||
|       combo_box_set (priv->combo, source->value); | ||||
|       break; | ||||
|     case GTK_PRINTER_OPTION_TYPE_ALTERNATIVE: | ||||
|       alternative_set (priv->box, source->value); | ||||
|       break; | ||||
|     case GTK_PRINTER_OPTION_TYPE_STRING: | ||||
|       gtk_entry_set_text (GTK_ENTRY (priv->entry), source->value); | ||||
|       break; | ||||
|  | ||||
		Reference in New Issue
	
	Block a user