1
// FIXME - need a destructor to clean up the printer queue strings.
7
#include <gtk/gtkframe.h>
8
#include <gtk/gtksizegroup.h>
9
#include <gtk/gtklabel.h>
10
#include <gtk/gtkcontainer.h>
12
#include "pp_printoutput.h"
21
static guint pp_printoutput_signals[LAST_SIGNAL] = { 0 };
23
static void pp_printoutput_class_init (pp_PrintOutputClass *klass);
24
static void pp_printoutput_init (pp_PrintOutput *stpuicombo);
27
static void printersel_changed(GtkWidget *wid,gpointer *ob)
29
cerr << "In printersel_changed()" << endl;
30
pp_PrintOutput *lo=(pp_PrintOutput *)ob;
32
const char *driver=stpui_printerselector_get_driver(STPUI_PRINTERSELECTOR(wid));
33
lo->po->SetString("Driver",driver);
35
g_signal_emit(G_OBJECT (ob),pp_printoutput_signals[CHANGED_SIGNAL], 0);
39
static void command_changed(GtkWidget *wid,gpointer *ob)
41
cerr << "In command_changed()" << endl;
42
pp_PrintOutput *lo=(pp_PrintOutput *)ob;
44
const char *command=gtk_entry_get_text(GTK_ENTRY(wid));
45
lo->po->SetString("Command",command);
49
static void pp_printoutput_queue_changed(GtkEntry *entry,gpointer *ud)
51
cerr << "In pp_printoutput_queue_changed()" << endl;
53
pp_PrintOutput *ob=PP_PRINTOUTPUT(ud);
54
PrintOutput *po=ob->po;
56
const char *val=gtk_entry_get_text(entry);
57
if(val && strlen(val))
59
po->SetString("Queue",val);
60
char *driver=po->GetPrinterDriver(val);
63
cerr << "Got driver: " << driver << " from Queue" << endl;
64
po->SetString("Driver",driver);
65
stpui_printerselector_set_driver(STPUI_PRINTERSELECTOR(ob->printersel),driver);
68
// char *command=po->GetPrintCommand(val);
71
// po->SetString("Command",command);
72
// gtk_entry_set_text(GTK_ENTRY(ob->string),command);
75
g_signal_emit(G_OBJECT (ob),pp_printoutput_signals[CHANGED_SIGNAL], 0);
81
void pp_printoutput_refresh(pp_PrintOutput *ob)
83
cerr << "In pp_printoutput_refresh()" << endl;
84
PrintOutput *po=ob->po;
86
char *driver=po->FindString("Driver");
89
cerr << "Setting driver to " << driver << endl;
90
stpui_printerselector_set_driver(STPUI_PRINTERSELECTOR(ob->printersel),driver);
92
char *command=po->FindString("Command");
95
gtk_entry_set_text(GTK_ENTRY(ob->string),command);
101
pp_printoutput_new (PrintOutput *po)
103
pp_PrintOutput *ob=PP_PRINTOUTPUT(g_object_new (pp_printoutput_get_type (), NULL));
104
gtk_box_set_spacing(GTK_BOX(ob),5);
110
GtkWidget *table=gtk_table_new(2,3,FALSE);
111
gtk_container_set_border_width(GTK_CONTAINER(table),5);
112
gtk_box_pack_start(GTK_BOX(ob),table,FALSE,FALSE,0);
113
gtk_widget_show(table);
115
label=gtk_label_new("Print Queue:");
116
gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,0,1);
117
gtk_widget_show(label);
119
ob->combo=gtk_combo_new();
120
gtk_combo_set_value_in_list(GTK_COMBO(ob->combo),TRUE,FALSE);
121
gtk_table_attach_defaults(GTK_TABLE(table),ob->combo,1,2,0,1);
122
gtk_widget_show(ob->combo);
127
count=po->GetPrinterCount();
131
char *queue=po->GetPrinterName(j);
132
ob->queues=g_list_append(ob->queues,(void *)queue);
137
gtk_combo_set_popdown_strings(GTK_COMBO(ob->combo),ob->queues);
138
gtk_widget_set_sensitive(GTK_WIDGET(ob->combo),TRUE);
141
gtk_widget_set_sensitive(GTK_WIDGET(ob->combo),FALSE);
143
char *queue=po->FindString("Queue");
144
if(queue && g_list_find_custom(ob->queues,queue,(GCompareFunc)strcmp))
145
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(ob->combo)->entry),queue);
147
g_signal_connect(GTK_COMBO(ob->combo)->entry,"changed",G_CALLBACK(pp_printoutput_queue_changed),ob);
150
label=gtk_label_new("Printer Model:");
151
gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,1,2);
152
gtk_widget_show(label);
154
ob->printersel=stpui_printerselector_new();
155
gtk_table_attach_defaults(GTK_TABLE(table),ob->printersel,1,2,1,2);
156
g_signal_connect(G_OBJECT(ob->printersel),"changed",G_CALLBACK(printersel_changed),ob);
158
stpui_printerselector_set_driver(STPUI_PRINTERSELECTOR(ob->printersel),po->FindString("Driver"));
159
gtk_widget_show(ob->printersel);
162
label=gtk_label_new("Print command:");
163
gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,2,3);
164
gtk_widget_show(label);
166
ob->string=gtk_entry_new();
167
gtk_table_attach_defaults(GTK_TABLE(table),ob->string,1,2,2,3);
168
gtk_widget_show(ob->string);
169
gtk_entry_set_text(GTK_ENTRY(ob->string),po->FindString("Command"));
170
g_signal_connect(G_OBJECT(ob->string),"changed",G_CALLBACK(command_changed),ob);
172
return(GTK_WIDGET(ob));
177
pp_printoutput_get_type (void)
179
static GType stpuic_type = 0;
183
static const GTypeInfo pp_printoutput_info =
185
sizeof (pp_PrintOutputClass),
186
NULL, /* base_init */
187
NULL, /* base_finalize */
188
(GClassInitFunc) pp_printoutput_class_init,
189
NULL, /* class_finalize */
190
NULL, /* class_data */
191
sizeof (pp_PrintOutput),
193
(GInstanceInitFunc) pp_printoutput_init,
195
stpuic_type = g_type_register_static (GTK_TYPE_VBOX, "pp_PrintOutput", &pp_printoutput_info, (GTypeFlags)0);
202
pp_printoutput_class_init (pp_PrintOutputClass *klass)
204
pp_printoutput_signals[CHANGED_SIGNAL] =
205
g_signal_new ("changed",
206
G_TYPE_FROM_CLASS (klass),
207
GSignalFlags(G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION),
208
G_STRUCT_OFFSET (pp_PrintOutputClass, changed),
210
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
215
pp_printoutput_init (pp_PrintOutput *ob)