[prev in list] [next in list] [prev in thread] [next in thread]
List: gimp-print-devel
Subject: [Gimp-print-devel] Multiple copies
From: Robert L Krawitz <rlk () alum ! mit ! edu>
Date: 2005-01-28 2:42:55
Message-ID: 200501280242.j0S2gtZx021115 () dsl092-065-009 ! bos1 ! dsl ! speakeasy ! net
[Download RAW message or body]
I like this rather better. It requires no changes to the printrc file format.
Index: include/gutenprintui2/gutenprintui.h
===================================================================
RCS file: /cvsroot/gimp-print/print/include/gutenprintui2/gutenprintui.h,v
retrieving revision 1.1
diff -u -r1.1 gutenprintui.h
--- include/gutenprintui2/gutenprintui.h 17 Sep 2004 18:38:01 -0000 1.1
+++ include/gutenprintui2/gutenprintui.h 28 Jan 2005 02:41:48 -0000
@@ -123,6 +123,9 @@
extern void stpui_plist_set_custom_command_n(stpui_plist_t *p, const char *val, int n);
extern const char *stpui_plist_get_custom_command(const stpui_plist_t *p);
+extern void stpui_plist_set_copy_count(stpui_plist_t *p, gint count);
+extern int stpui_plist_get_copy_count(const stpui_plist_t *p);
+
extern void stpui_plist_set_current_standard_command(stpui_plist_t *p, const char *val);
extern void stpui_plist_set_current_standard_command_n(stpui_plist_t *p, const char *val, int n);
extern const char *stpui_plist_get_current_standard_command(const stpui_plist_t *p);
Index: src/gutenprintui2/panel.c
===================================================================
RCS file: /cvsroot/gimp-print/print/src/gutenprintui2/panel.c,v
retrieving revision 1.1
diff -u -r1.1 panel.c
--- src/gutenprintui2/panel.c 17 Sep 2004 18:38:14 -0000 1.1
+++ src/gutenprintui2/panel.c 28 Jan 2005 02:41:49 -0000
@@ -134,6 +134,8 @@
static GtkWidget *printer_features_table;
static GtkWidget *color_adjustment_table;
+static GtkWidget *copy_count_spin_button;
+
static gboolean preview_valid = FALSE;
static gboolean frame_valid = FALSE;
static gboolean need_exposure = FALSE;
@@ -233,6 +235,8 @@
static void position_callback (GtkWidget *widget);
static void position_button_callback (GtkWidget *widget,
gpointer data);
+static void copy_count_callback (GtkAdjustment *widget,
+ gpointer data);
static void plist_build_combo(GtkWidget *combo,
GtkWidget *label,
stp_string_list_t *items,
@@ -1359,6 +1363,50 @@
}
static void
+create_copy_number_frame(void)
+{
+ GtkWidget *frame;
+ GtkWidget *vbox;
+ GtkWidget *event_box;
+ GtkAdjustment *adj;
+
+ frame = gtk_frame_new (_("Number of Copies"));
+ gtk_box_pack_start (GTK_BOX (right_vbox), frame, FALSE, TRUE, 0);
+ gtk_widget_show (frame);
+
+ vbox = gtk_hbox_new (FALSE, 2);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
+ gtk_container_add (GTK_CONTAINER (frame), vbox);
+ gtk_widget_show (vbox);
+
+ event_box = gtk_event_box_new ();
+ gtk_container_add (GTK_CONTAINER (vbox), event_box);
+ stpui_set_help_data(event_box,
+ _("Select the number of copies to print; "
+ "a value between 1 and 100"));
+ gtk_widget_show (event_box);
+
+ /*
+ * Number of Copies Spin Button
+ */
+
+ adj = (GtkAdjustment *) gtk_adjustment_new (1.0f, 1.0f, 100.0f,
+ 1.0f, 5.0f, 0.0f);
+ copy_count_spin_button = gtk_spin_button_new (adj, 0, 0);
+ gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (copy_count_spin_button), FALSE);
+ gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (copy_count_spin_button), TRUE);
+ gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (copy_count_spin_button),
+ GTK_UPDATE_IF_VALID);
+
+ g_signal_connect(G_OBJECT (adj), "value_changed",
+ G_CALLBACK (copy_count_callback),
+ NULL);
+
+ gtk_container_add (GTK_CONTAINER (event_box), copy_count_spin_button);
+ gtk_widget_show(copy_count_spin_button);
+}
+
+static void
create_positioning_frame (void)
{
GtkWidget *frame;
@@ -2276,6 +2324,7 @@
create_printer_settings_frame ();
create_units_frame();
create_paper_size_frame();
+ create_copy_number_frame();
create_positioning_frame ();
create_scaling_frame ();
create_image_settings_frame ();
@@ -2833,17 +2882,23 @@
}
static void
-do_all_updates(void)
+update_standard_print_command(void)
{
- gint i;
char *label_text =
stpui_build_standard_print_command(pv, stp_get_printer(pv->v));
+ gtk_entry_set_text(GTK_ENTRY(standard_cmd_entry), label_text);
+ g_free(label_text);
+}
+
+static void
+do_all_updates(void)
+{
+ gint i;
suppress_preview_update++;
set_orientation(pv->orientation);
invalidate_preview_thumbnail ();
preview_update ();
- gtk_entry_set_text(GTK_ENTRY(standard_cmd_entry), label_text);
- g_free(label_text);
+ update_standard_print_command();
if (pv->scaling < 0)
{
@@ -2899,6 +2954,14 @@
}
static void
+copy_count_callback(GtkAdjustment *adjustment, gpointer data)
+{
+ gint copy_count = (gint) adjustment->value;
+ stpui_plist_set_copy_count(pv, copy_count);
+ update_standard_print_command();
+}
+
+static void
auto_paper_size_callback(GtkWidget *widget, gpointer data)
{
auto_paper_size =
@@ -3056,6 +3119,8 @@
stp_free(tmp);
gtk_entry_set_text(GTK_ENTRY(custom_command_entry),
stpui_plist_get_custom_command(pv));
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(copy_count_spin_button),
+ (gfloat) stpui_plist_get_copy_count(pv));
do_all_updates();
setup_update ();
@@ -3321,6 +3386,7 @@
gtk_entry_set_editable(GTK_ENTRY(custom_command_entry), FALSE);
gtk_widget_hide(GTK_WIDGET(file_browser));
gtk_widget_set_sensitive(file_button, FALSE);
+ gtk_widget_set_sensitive(copy_count_spin_button, TRUE);
stpui_plist_set_command_type(pv, COMMAND_TYPE_DEFAULT);
}
else if (strcmp((const char *) data, "Custom") == 0)
@@ -3333,6 +3399,7 @@
gtk_entry_set_editable(GTK_ENTRY(custom_command_entry), TRUE);
gtk_widget_hide(GTK_WIDGET(file_browser));
gtk_widget_set_sensitive(file_button, FALSE);
+ gtk_widget_set_sensitive(copy_count_spin_button, FALSE);
stpui_plist_set_command_type(pv, COMMAND_TYPE_CUSTOM);
}
else if (strcmp((const char *) data, "File") == 0)
@@ -3344,6 +3411,7 @@
gtk_widget_set_sensitive(custom_command_entry, FALSE);
gtk_entry_set_editable(GTK_ENTRY(custom_command_entry), FALSE);
gtk_widget_set_sensitive(file_button, TRUE);
+ gtk_widget_set_sensitive(copy_count_spin_button, FALSE);
stpui_plist_set_command_type(pv, COMMAND_TYPE_FILE);
}
}
Index: src/gutenprintui2/plist.c
===================================================================
RCS file: /cvsroot/gimp-print/print/src/gutenprintui2/plist.c,v
retrieving revision 1.1
diff -u -r1.1 plist.c
--- src/gutenprintui2/plist.c 17 Sep 2004 18:38:14 -0000 1.1
+++ src/gutenprintui2/plist.c 28 Jan 2005 02:41:50 -0000
@@ -61,6 +61,7 @@
static gint image_channel_depth = 8;
static stp_string_list_t *default_parameters = NULL;
stp_string_list_t *stpui_system_print_queues;
+static const char *copy_count_name = "STPUICopyCount";
#define SAFE_FREE(x) \
do \
@@ -79,6 +80,7 @@
const char *raw_flag;
const char *key_file;
const char *scan_command;
+ const char *copy_count_command;
} print_system_t;
/*
@@ -86,24 +88,32 @@
*/
static const print_system_t default_printing_system =
{ "SysV", N_("System V lp"), "lp -s", "-d", "-oraw", "/usr/bin/lp",
- "/usr/bin/lpstat -v | grep -i '^device for ' | awk '{print $3}' | sed 's/://'" };
+ "/usr/bin/lpstat -v | grep -i '^device for ' | awk '{print $3}' | sed 's/://'",
+ "-n" };
static print_system_t known_printing_systems[] =
{
{ "CUPS", N_("CUPS"), "lp -s", "-d", "-oraw", "/usr/sbin/cupsd",
- "/usr/bin/lpstat -v | grep -i '^device for ' | awk '{print $3}' | sed 's/://'" },
+ "/usr/bin/lpstat -v | grep -i '^device for ' | awk '{print $3}' | sed 's/://'",
+ "-n" },
{ "SysV", N_("System V lp"), "lp -s", "-d", "-oraw", "/usr/bin/lp",
- "/usr/bin/lpstat -v | grep -i '^device for ' | awk '{print $3}' | sed 's/://'" },
+ "/usr/bin/lpstat -v | grep -i '^device for ' | awk '{print $3}' | sed 's/://'",
+ "-n" },
{ "lpd", N_("Berkeley lpd (/etc/lpc)"), "lpr", "-P", "-l", "/etc/lpc",
- "/etc/lpc status | grep '^...*:' | sed 's/:.*//'" },
+ "/etc/lpc status | grep '^...*:' | sed 's/:.*//'",
+ "-#" },
{ "lpd", N_("Berkeley lpd (/usr/bsd/lpc)"), "lpr", "-P", "-l", "/usr/bsd/lpc",
- "/usr/bsd/lpc status | grep '^...*:' | sed 's/:.*//'" },
+ "/usr/bsd/lpc status | grep '^...*:' | sed 's/:.*//'",
+ "-#" },
{ "lpd", N_("Berkeley lpd (/usr/etc/lpc"), "lpr", "-P", "-l", "/usr/etc/lpc",
- "/usr/etc/lpc status | grep '^...*:' | sed 's/:.*//'" },
+ "/usr/etc/lpc status | grep '^...*:' | sed 's/:.*//'",
+ "-#" },
{ "lpd", N_("Berkeley lpd (/usr/libexec/lpc)"), "lpr", "-P", "-l", "/usr/libexec/lpc",
- "/usr/libexec/lpc status | grep '^...*:' | sed 's/:.*//'" },
+ "/usr/libexec/lpc status | grep '^...*:' | sed 's/:.*//'",
+ "-#" },
{ "lpd", N_("Berkeley lpd (/usr/sbin/lpc)"), "lpr", "-P", "-l", "/usr/sbin/lpc",
- "/usr/sbin/lpc status | grep '^...*:' | sed 's/:.*//'" },
+ "/usr/sbin/lpc status | grep '^...*:' | sed 's/:.*//'",
+ "-#" },
};
static unsigned print_system_count = sizeof(known_printing_systems) / sizeof(print_system_t);
@@ -166,8 +176,10 @@
const char *queue_name = stpui_plist_get_queue_name(plist);
const char *extra_options = stpui_plist_get_extra_printer_options(plist);
const char *family = stp_printer_get_family(printer);
+ int copy_count = stpui_plist_get_copy_count(plist);
int raw = 0;
char *print_cmd;
+ char *count_string = NULL;
if (!queue_name)
queue_name = "";
identify_print_system();
@@ -175,13 +187,20 @@
raw = 0;
else
raw = 1;
- stp_asprintf(&print_cmd, "%s %s %s %s%s%s",
+
+ if (copy_count > 1)
+ stp_asprintf(&count_string, "%s %d ",
+ global_printing_system->copy_count_command, copy_count);
+
+ stp_asprintf(&print_cmd, "%s %s %s %s %s%s%s",
global_printing_system->print_command,
queue_name[0] ? global_printing_system->queue_select : "",
queue_name[0] ? queue_name : "",
+ count_string ? count_string : "",
raw ? global_printing_system->raw_flag : "",
extra_options ? " " : "",
extra_options ? extra_options : "");
+ SAFE_FREE(count_string);
return print_cmd;
}
@@ -263,6 +282,22 @@
}
void
+stpui_plist_set_copy_count(stpui_plist_t *p, gint copy_count)
+{
+ if (copy_count > 0)
+ stp_set_int_parameter(p->v, copy_count_name, copy_count);
+}
+
+gint
+stpui_plist_get_copy_count(const stpui_plist_t *p)
+{
+ if (stp_check_int_parameter(p->v, copy_count_name, STP_PARAMETER_ACTIVE))
+ return stp_get_int_parameter(p->v, copy_count_name);
+ else
+ return 1;
+}
+
+void
stpui_set_image_type(const char *itype)
{
image_type = g_strdup(itype);
@@ -296,6 +331,7 @@
printer->auto_size_roll_feed_paper = 0;
printer->unit = 0;
printer->v = stp_vars_create();
+ stpui_plist_set_copy_count(printer, 1);
stp_set_string_parameter(printer->v, "InputImageType", image_type);
if (image_raw_channels)
{
@@ -340,6 +376,7 @@
stpui_plist_set_custom_command(vd, stpui_plist_get_custom_command(vs));
stpui_plist_set_current_standard_command(vd, stpui_plist_get_current_standard_command(vs));
stpui_plist_set_output_filename(vd, stpui_plist_get_output_filename(vs));
+ stpui_plist_set_copy_count(vd, stpui_plist_get_copy_count(vs));
}
static stpui_plist_t *
@@ -1020,6 +1057,8 @@
fprintf(fp, " Top: %d\n", stp_get_top(p->v));
fprintf(fp, " Custom_Page_Width: %d\n", stp_get_page_width(p->v));
fprintf(fp, " Custom_Page_Height: %d\n", stp_get_page_height(p->v));
+ fprintf(fp, " Parameter %s Int True %d\n", copy_count_name,
+ stpui_plist_get_copy_count(p));
for (j = 0; j < count; j++)
{
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Gimp-print-devel mailing list
Gimp-print-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gimp-print-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic