summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Kasik <mkasik@redhat.com>2009-08-11 09:24:18 +0200
committerMatthias Clasen <mclasen@redhat.com>2009-08-28 22:25:34 -0400
commit2e4345ed50e4d715adab5b6660f0a0a2d26b2aeb (patch)
tree9d35a1866184e03b1baed344ccfb1af496492a54
parent8b774172b5d2ca52544abda840a74373eee7abe8 (diff)
downloadgdk-pixbuf-2e4345ed50e4d715adab5b6660f0a0a2d26b2aeb.tar.gz
Print when Enter pressed in certain GtkEntries of the print dialog
Print when Enter pressed in Name entry or Command Line entry in the print dialog (#564695). Add gtk_printer_option_set_activates_default() function and gtk_printer_option_get_activates_default() function to control behaviour of GtkPrinterOptionWidget.
-rw-r--r--gtk/gtk.symbols2
-rw-r--r--gtk/gtkprinteroption.c18
-rw-r--r--gtk/gtkprinteroption.h41
-rw-r--r--gtk/gtkprinteroptionwidget.c4
-rw-r--r--modules/printbackends/file/gtkprintbackendfile.c1
-rw-r--r--modules/printbackends/lpr/gtkprintbackendlpr.c1
6 files changed, 49 insertions, 18 deletions
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 9e99266f7..12eb7d8df 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -2905,6 +2905,8 @@ gtk_printer_option_clear_has_conflict
gtk_printer_option_set_boolean
gtk_printer_option_allocate_choices
gtk_printer_option_choices_from_array
+gtk_printer_option_set_activates_default
+gtk_printer_option_get_activates_default
#endif
#endif
#endif
diff --git a/gtk/gtkprinteroption.c b/gtk/gtkprinteroption.c
index 983dc65d5..47fcd3275 100644
--- a/gtk/gtkprinteroption.c
+++ b/gtk/gtkprinteroption.c
@@ -63,6 +63,7 @@ static void
gtk_printer_option_init (GtkPrinterOption *option)
{
option->value = g_strdup ("");
+ option->activates_default = FALSE;
}
static void
@@ -215,6 +216,23 @@ gtk_printer_option_has_choice (GtkPrinterOption *option,
return FALSE;
}
+void
+gtk_printer_option_set_activates_default (GtkPrinterOption *option,
+ gboolean activates)
+{
+ g_return_if_fail (GTK_IS_PRINTER_OPTION (option));
+
+ option->activates_default = activates;
+}
+
+gboolean
+gtk_printer_option_get_activates_default (GtkPrinterOption *option)
+{
+ g_return_val_if_fail (GTK_IS_PRINTER_OPTION (option), FALSE);
+
+ return option->activates_default;
+}
+
#define __GTK_PRINTER_OPTION_C__
#include "gtkaliasdef.c"
diff --git a/gtk/gtkprinteroption.h b/gtk/gtkprinteroption.h
index cce698696..f1831a31c 100644
--- a/gtk/gtkprinteroption.h
+++ b/gtk/gtkprinteroption.h
@@ -70,6 +70,8 @@ struct _GtkPrinterOption
char **choices;
char **choices_display;
+ gboolean activates_default;
+
gboolean has_conflict;
char *group;
};
@@ -92,24 +94,27 @@ struct _GtkPrinterOptionClass
GType gtk_printer_option_get_type (void) G_GNUC_CONST;
-GtkPrinterOption *gtk_printer_option_new (const char *name,
- const char *display_text,
- GtkPrinterOptionType type);
-void gtk_printer_option_set (GtkPrinterOption *option,
- const char *value);
-void gtk_printer_option_set_has_conflict (GtkPrinterOption *option,
- gboolean has_conflict);
-void gtk_printer_option_clear_has_conflict (GtkPrinterOption *option);
-void gtk_printer_option_set_boolean (GtkPrinterOption *option,
- gboolean value);
-void gtk_printer_option_allocate_choices (GtkPrinterOption *option,
- int num);
-void gtk_printer_option_choices_from_array (GtkPrinterOption *option,
- int num_choices,
- char *choices[],
- char *choices_display[]);
-gboolean gtk_printer_option_has_choice (GtkPrinterOption *option,
- const char *choice);
+GtkPrinterOption *gtk_printer_option_new (const char *name,
+ const char *display_text,
+ GtkPrinterOptionType type);
+void gtk_printer_option_set (GtkPrinterOption *option,
+ const char *value);
+void gtk_printer_option_set_has_conflict (GtkPrinterOption *option,
+ gboolean has_conflict);
+void gtk_printer_option_clear_has_conflict (GtkPrinterOption *option);
+void gtk_printer_option_set_boolean (GtkPrinterOption *option,
+ gboolean value);
+void gtk_printer_option_allocate_choices (GtkPrinterOption *option,
+ int num);
+void gtk_printer_option_choices_from_array (GtkPrinterOption *option,
+ int num_choices,
+ char *choices[],
+ char *choices_display[]);
+gboolean gtk_printer_option_has_choice (GtkPrinterOption *option,
+ const char *choice);
+void gtk_printer_option_set_activates_default (GtkPrinterOption *option,
+ gboolean activates);
+gboolean gtk_printer_option_get_activates_default (GtkPrinterOption *option);
G_END_DECLS
diff --git a/gtk/gtkprinteroptionwidget.c b/gtk/gtkprinteroptionwidget.c
index 38cdf0080..d91b51c59 100644
--- a/gtk/gtkprinteroptionwidget.c
+++ b/gtk/gtkprinteroptionwidget.c
@@ -767,6 +767,8 @@ construct_widgets (GtkPrinterOptionWidget *widget)
case GTK_PRINTER_OPTION_TYPE_STRING:
priv->entry = gtk_entry_new ();
+ gtk_entry_set_activates_default (GTK_ENTRY (priv->entry),
+ gtk_printer_option_get_activates_default (source));
gtk_widget_show (priv->entry);
gtk_box_pack_start (GTK_BOX (widget), priv->entry, TRUE, TRUE, 0);
g_signal_connect (priv->entry, "changed", G_CALLBACK (entry_changed_cb), widget);
@@ -792,6 +794,8 @@ construct_widgets (GtkPrinterOptionWidget *widget)
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
g_object_set (priv->combo, "local-only", FALSE, NULL);
+ gtk_entry_set_activates_default (GTK_ENTRY (priv->entry),
+ gtk_printer_option_get_activates_default (source));
label = gtk_label_new_with_mnemonic (_("_Name:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
diff --git a/modules/printbackends/file/gtkprintbackendfile.c b/modules/printbackends/file/gtkprintbackendfile.c
index c44c24cfd..980fdea3b 100644
--- a/modules/printbackends/file/gtkprintbackendfile.c
+++ b/modules/printbackends/file/gtkprintbackendfile.c
@@ -603,6 +603,7 @@ file_printer_get_options (GtkPrinter *printer,
option = gtk_printer_option_new ("gtk-main-page-custom-input", _("File"),
GTK_PRINTER_OPTION_TYPE_FILESAVE);
+ gtk_printer_option_set_activates_default (option, TRUE);
gtk_printer_option_set (option, uri);
g_free (uri);
option->group = g_strdup ("GtkPrintDialogExtension");
diff --git a/modules/printbackends/lpr/gtkprintbackendlpr.c b/modules/printbackends/lpr/gtkprintbackendlpr.c
index fa6196df7..aece2b295 100644
--- a/modules/printbackends/lpr/gtkprintbackendlpr.c
+++ b/modules/printbackends/lpr/gtkprintbackendlpr.c
@@ -431,6 +431,7 @@ lpr_printer_get_options (GtkPrinter *printer,
g_object_unref (option);
option = gtk_printer_option_new ("gtk-main-page-custom-input", _("Command Line"), GTK_PRINTER_OPTION_TYPE_STRING);
+ gtk_printer_option_set_activates_default (option, TRUE);
option->group = g_strdup ("GtkPrintDialogExtension");
if (settings != NULL &&
(command = gtk_print_settings_get (settings, "lpr-commandline"))!= NULL)