[gtk+] Print when Enter pressed in certain GtkEntries of the print dialog
- From: Marek Kašík <mkasik src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+] Print when Enter pressed in certain GtkEntries of the print dialog
- Date: Tue, 11 Aug 2009 07:25:14 +0000 (UTC)
commit 70efa7331100df0743bd8a1b85231dc3ec67c24d
Author: Marek Kasik <mkasik redhat com>
Date: Tue Aug 11 09:24:18 2009 +0200
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.
gtk/gtk.symbols | 2 +
gtk/gtkprinteroption.c | 18 +++++++++
gtk/gtkprinteroption.h | 41 ++++++++++++---------
gtk/gtkprinteroptionwidget.c | 4 ++
modules/printbackends/file/gtkprintbackendfile.c | 1 +
modules/printbackends/lpr/gtkprintbackendlpr.c | 1 +
6 files changed, 49 insertions(+), 18 deletions(-)
---
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 64e69ab..e4ccad2 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -2957,6 +2957,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 983dc65..47fcd32 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 cce6986..f1831a3 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 38cdf00..d91b51c 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 bc58751..0cf114f 100644
--- a/modules/printbackends/file/gtkprintbackendfile.c
+++ b/modules/printbackends/file/gtkprintbackendfile.c
@@ -645,6 +645,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 9d9c932..a20f0d3 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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]