~
2006-06-17 Matthias Clasen <mclasen@redhat.com> * gtk/gtkprintunixdialog.c: Clean up the handling of printer-specific options. There is just one extension point on the main tab now, and all options in the GtkPrintDialogExtension group are put there.
This commit is contained in:

committed by
Matthias Clasen

parent
320660fb81
commit
9ee7d66fa3
@ -1,5 +1,10 @@
|
|||||||
2006-06-17 Matthias Clasen <mclasen@redhat.com>
|
2006-06-17 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* gtk/gtkprintunixdialog.c: Clean up the handling of
|
||||||
|
printer-specific options. There is just one extension point on the
|
||||||
|
main tab now, and all options in the GtkPrintDialogExtension
|
||||||
|
group are put there.
|
||||||
|
|
||||||
* gtk/gtkprinteroption.h:
|
* gtk/gtkprinteroption.h:
|
||||||
* gtk/gtkprinteroption.c: Add GTK_PRINTER_OPTION_TYPE_ALTERNATIVE
|
* gtk/gtkprinteroption.c: Add GTK_PRINTER_OPTION_TYPE_ALTERNATIVE
|
||||||
which is semantically the same as PICKONE, but is intended to
|
which is semantically the same as PICKONE, but is intended to
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
2006-06-17 Matthias Clasen <mclasen@redhat.com>
|
2006-06-17 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* gtk/gtkprintunixdialog.c: Clean up the handling of
|
||||||
|
printer-specific options. There is just one extension point on the
|
||||||
|
main tab now, and all options in the GtkPrintDialogExtension
|
||||||
|
group are put there.
|
||||||
|
|
||||||
* gtk/gtkprinteroption.h:
|
* gtk/gtkprinteroption.h:
|
||||||
* gtk/gtkprinteroption.c: Add GTK_PRINTER_OPTION_TYPE_ALTERNATIVE
|
* gtk/gtkprinteroption.c: Add GTK_PRINTER_OPTION_TYPE_ALTERNATIVE
|
||||||
which is semantically the same as PICKONE, but is intended to
|
which is semantically the same as PICKONE, but is intended to
|
||||||
|
@ -489,23 +489,23 @@ radio_changed_cb (GtkWidget *button,
|
|||||||
emit_changed (widget);
|
emit_changed (widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
select_maybe (GtkWidget *widget,
|
||||||
|
const gchar *value)
|
||||||
|
{
|
||||||
|
char *v = g_object_get_data (G_OBJECT (widget), "value");
|
||||||
|
|
||||||
|
if (strcmp (value, v) == 0)
|
||||||
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
alternative_set (GtkWidget *box,
|
alternative_set (GtkWidget *box,
|
||||||
const gchar *value)
|
const gchar *value)
|
||||||
{
|
{
|
||||||
GList *children, *l;
|
gtk_container_foreach (GTK_CONTAINER (box),
|
||||||
|
(GtkCallback) select_maybe,
|
||||||
children = gtk_container_get_children (GTK_CONTAINER (box));
|
value);
|
||||||
|
|
||||||
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 *
|
static GSList *
|
||||||
|
@ -106,8 +106,6 @@ enum {
|
|||||||
PRINTER_LIST_N_COLS
|
PRINTER_LIST_N_COLS
|
||||||
};
|
};
|
||||||
|
|
||||||
#define _EXTENSION_POINT_MAIN_PAGE_CUSTOM_INPUT "gtk-main-page-custom-input"
|
|
||||||
|
|
||||||
struct GtkPrintUnixDialogPrivate
|
struct GtkPrintUnixDialogPrivate
|
||||||
{
|
{
|
||||||
GtkWidget *notebook;
|
GtkWidget *notebook;
|
||||||
@ -162,7 +160,7 @@ struct GtkPrintUnixDialogPrivate
|
|||||||
GtkWidget *advanced_vbox;
|
GtkWidget *advanced_vbox;
|
||||||
GtkWidget *advanced_page;
|
GtkWidget *advanced_page;
|
||||||
|
|
||||||
GHashTable *extension_points;
|
GtkWidget *extension_point;
|
||||||
|
|
||||||
/* These are set initially on selected printer (either default printer,
|
/* These are set initially on selected printer (either default printer,
|
||||||
* printer taken from set settings, or user-selected), but when any setting
|
* printer taken from set settings, or user-selected), but when any setting
|
||||||
@ -268,9 +266,6 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
|
|||||||
priv->print_backends = NULL;
|
priv->print_backends = NULL;
|
||||||
priv->current_page = -1;
|
priv->current_page = -1;
|
||||||
|
|
||||||
priv->extension_points = g_hash_table_new (g_str_hash,
|
|
||||||
g_str_equal);
|
|
||||||
|
|
||||||
priv->page_setup = gtk_page_setup_new ();
|
priv->page_setup = gtk_page_setup_new ();
|
||||||
|
|
||||||
g_signal_connect (dialog,
|
g_signal_connect (dialog,
|
||||||
@ -338,12 +333,6 @@ gtk_print_unix_dialog_finalize (GObject *object)
|
|||||||
priv->options = NULL;
|
priv->options = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->extension_points)
|
|
||||||
{
|
|
||||||
g_hash_table_unref (priv->extension_points);
|
|
||||||
priv->extension_points = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (priv->page_setup)
|
if (priv->page_setup)
|
||||||
{
|
{
|
||||||
g_object_unref (priv->page_setup);
|
g_object_unref (priv->page_setup);
|
||||||
@ -730,15 +719,10 @@ setup_option (GtkPrintUnixDialog *dialog,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
add_option_to_extension_point (GtkPrinterOption *option,
|
add_option_to_extension_point (GtkPrinterOption *option,
|
||||||
gpointer user_data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GHashTable *extension_points = (GHashTable *) user_data;
|
GtkWidget *extension_point = data;
|
||||||
GtkWidget *widget, *extension_hbox;
|
GtkWidget *widget;
|
||||||
|
|
||||||
extension_hbox = g_hash_table_lookup (extension_points, option->name);
|
|
||||||
|
|
||||||
if (extension_hbox)
|
|
||||||
{
|
|
||||||
|
|
||||||
widget = gtk_printer_option_widget_new (option);
|
widget = gtk_printer_option_widget_new (option);
|
||||||
gtk_widget_show (widget);
|
gtk_widget_show (widget);
|
||||||
@ -757,13 +741,10 @@ add_option_to_extension_point (GtkPrinterOption *option,
|
|||||||
gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (hbox);
|
gtk_widget_show (hbox);
|
||||||
|
|
||||||
gtk_box_pack_start (GTK_BOX (extension_hbox), hbox, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (extension_point), hbox, FALSE, FALSE, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
gtk_box_pack_start (GTK_BOX (extension_hbox), widget, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (extension_point), widget, FALSE, FALSE, 0);
|
||||||
}
|
|
||||||
else
|
|
||||||
g_warning ("Extension point %s requested but not found.", option->name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -964,6 +945,11 @@ update_dialog_from_settings (GtkPrintUnixDialog *dialog)
|
|||||||
priv->color_table,
|
priv->color_table,
|
||||||
priv->color_page);
|
priv->color_page);
|
||||||
|
|
||||||
|
gtk_printer_option_set_foreach_in_group (priv->options,
|
||||||
|
"GtkPrintDialogExtension",
|
||||||
|
add_option_to_extension_point,
|
||||||
|
priv->extension_point);
|
||||||
|
|
||||||
/* Put the rest of the groups in the advanced page */
|
/* Put the rest of the groups in the advanced page */
|
||||||
groups = gtk_printer_option_set_get_groups (priv->options);
|
groups = gtk_printer_option_set_get_groups (priv->options);
|
||||||
|
|
||||||
@ -977,18 +963,10 @@ update_dialog_from_settings (GtkPrintUnixDialog *dialog)
|
|||||||
|
|
||||||
if (strcmp (group, "ImageQualityPage") == 0 ||
|
if (strcmp (group, "ImageQualityPage") == 0 ||
|
||||||
strcmp (group, "ColorPage") == 0 ||
|
strcmp (group, "ColorPage") == 0 ||
|
||||||
strcmp (group, "FinishingPage") == 0)
|
strcmp (group, "FinishingPage") == 0 ||
|
||||||
|
strcmp (group, "GtkPrintDialogExtension") == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (strcmp (group, "GtkPrintDialogExtention") == 0)
|
|
||||||
{
|
|
||||||
gtk_printer_option_set_foreach_in_group (priv->options,
|
|
||||||
group,
|
|
||||||
add_option_to_extension_point,
|
|
||||||
priv->extension_points);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
table = gtk_table_new (1, 2, FALSE);
|
table = gtk_table_new (1, 2, FALSE);
|
||||||
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
||||||
gtk_table_set_col_spacings (GTK_TABLE (table), 12);
|
gtk_table_set_col_spacings (GTK_TABLE (table), 12);
|
||||||
@ -1143,9 +1121,7 @@ remove_custom_widget (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
extension_point_clear_children (const gchar *key,
|
extension_point_clear_children (GtkContainer *container)
|
||||||
GtkContainer *container,
|
|
||||||
gpointer data)
|
|
||||||
{
|
{
|
||||||
gtk_container_foreach (container,
|
gtk_container_foreach (container,
|
||||||
(GtkCallback)remove_custom_widget,
|
(GtkCallback)remove_custom_widget,
|
||||||
@ -1172,9 +1148,7 @@ clear_per_printer_ui (GtkPrintUnixDialog *dialog)
|
|||||||
gtk_container_foreach (GTK_CONTAINER (priv->advanced_vbox),
|
gtk_container_foreach (GTK_CONTAINER (priv->advanced_vbox),
|
||||||
(GtkCallback)gtk_widget_destroy,
|
(GtkCallback)gtk_widget_destroy,
|
||||||
NULL);
|
NULL);
|
||||||
g_hash_table_foreach (priv->extension_points,
|
extension_point_clear_children (priv->extension_point);
|
||||||
(GHFunc) extension_point_clear_children,
|
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1481,9 +1455,7 @@ create_main_page (GtkPrintUnixDialog *dialog)
|
|||||||
custom_input = gtk_hbox_new (FALSE, 18);
|
custom_input = gtk_hbox_new (FALSE, 18);
|
||||||
gtk_widget_show (custom_input);
|
gtk_widget_show (custom_input);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), custom_input, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox), custom_input, FALSE, FALSE, 0);
|
||||||
g_hash_table_insert (priv->extension_points,
|
priv->extension_point = custom_input;
|
||||||
_EXTENSION_POINT_MAIN_PAGE_CUSTOM_INPUT,
|
|
||||||
custom_input);
|
|
||||||
|
|
||||||
hbox = gtk_hbox_new (FALSE, 18);
|
hbox = gtk_hbox_new (FALSE, 18);
|
||||||
gtk_widget_show (hbox);
|
gtk_widget_show (hbox);
|
||||||
|
Reference in New Issue
Block a user