Initial import of the CDE 2.1.30 sources from the Open Group.

This commit is contained in:
Peter Howkins
2012-03-10 18:21:40 +00:00
commit 83b6996daa
18978 changed files with 3945623 additions and 0 deletions

View File

@@ -0,0 +1,121 @@
/* $TOG: DtActions.C /main/4 1998/08/03 16:30:18 mgreess $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#include "stdlib.h"
#include "DtActions.h"
#include "DtMainW.h"
#include "Button.h"
#include "Sep.h"
DtActions::DtActions(AnyUI *parent,
char *name,
char *mnemonic)
: Menu(parent, name, mnemonic)
{
// Empty
}
class DtAction : public Button {
public:
static void ActionCB(void *);
char *actionReferenceName;
ActionCallback actionCallback;
void *actionCallbackData;
~DtAction();
DtAction(char *category, AnyUI *parent, char *name, char *mnemonic,
char *acceleratorText, char *accelerator, char *actionReferenceName,
ActionCallback callbackCB, void *callback_data);
};
DtAction::DtAction(char *category,
AnyUI *parent,
char *name,
char *mnemonic,
char *acceleratorText,
char *accelerator,
char *actionName,
ActionCallback callbackCB,
void *callback_data)
: Button(category, parent, name, PUSH_BUTTON, NULL, NULL,
mnemonic, acceleratorText, accelerator)
{
actionReferenceName = strdup(actionName);
actionCallback = callbackCB;
actionCallbackData = callback_data;
Callback(ActionCB);
}
DtAction::~DtAction()
{
free(actionReferenceName);
}
void DtAction::ActionCB(void *callback_data)
{
DtAction *action = (DtAction *) callback_data;
BaseUI *obj = ((DtActions *)action->Parent())->SelectedObject();
if (obj && action->actionCallback)
(*action->actionCallback)(action->actionCallbackData, obj,
action->actionReferenceName);
}
void DtActions::AddSep(char *objectClassName)
{
new Sep(objectClassName, this);
}
void DtActions::AddAction(char *name, char *category, char *actionReferenceName,
ActionCallback callback, void *callback_data,
char *mnemonic, char *acceleratorText,
char *accelerator)
{
new DtAction(category, this, name, mnemonic, acceleratorText, accelerator,
actionReferenceName, callback, callback_data);
}
void DtActions::UpdateActions(int n_items, BaseUI *obj)
{
if (n_items == 1)
{
Active(true);
int i;
for (i = 0; i < _numChildren; i++)
{
if (!_children[i]->Category() ||
!STRCMP(_children[i]->Category(), obj->Category()))
_children[i]->Visible(true);
else
_children[i]->Visible(false);
}
}
else
Active(false);
selected_object = obj;
}
boolean DtActions::HandleHelpRequest()
{
DtMainW *window = (DtMainW *)Parent()->Parent();
if (Active())
{
if (strcmp(selected_object->Category(), "Queue"))
window->DisplayHelp("SelectedPrintJobMenuDE");
else
window->DisplayHelp("SelectedPrinterMenuDE");
}
else if (window->PrinterAppMode() == PRINT_MANAGER)
window->DisplayHelp("SelectedMenuDE");
else
window->DisplayHelp("PJSelectedMenuDE");
return true;
}

View File

@@ -0,0 +1,47 @@
/* $XConsortium: DtActions.h /main/3 1995/11/06 09:34:07 rswiston $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifndef DTACTIONS_H
#define DTACTIONS_H
#include "Menu.h"
typedef void (*ActionCallback) (void *callback_data, BaseUI *object,
char *actionReferenceName);
class DtWorkArea;
class DtActions : public Menu
{
friend class DtWorkArea;
protected:
int n_categories;
char **categories;
void UpdateActions(int n_items, BaseUI *obj);
BaseUI *selected_object;
public:
DtActions(AnyUI *parent,
char *name,
char *mnemonic = NULL);
void AddAction(char *name, char *category,
char *actionReferenceName, ActionCallback callback,
void *callback_data, char *mnemonic = NULL,
char *acceleratorText = NULL, char *accelerator = NULL);
void AddSep(char *category);
BaseUI *SelectedObject() { return selected_object; }
boolean HandleHelpRequest();
};
#endif // DTACTIONS_H

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,104 @@
/* $XConsortium: DtApp.h /main/3 1995/11/06 09:34:32 rswiston $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifndef DTAPP_H
#define DTAPP_H
#include "Application.h"
#include "DtPrinterIcon.h"
#include "DtSetPref.h"
class DtMainW;
class BaseObj;
class DtPrtJobIcon;
extern const char *PROPERTY;
extern const char *HELP;
extern const char *FIND;
extern const char *EXIT;
extern const char *HIDE;
extern const char *RENAME;
extern const char *OPEN;
extern const char *CLOSE;
extern const char *PRINTERS_DIR;
class DtApp : public Application
{
friend void InitQueueDetails(BaseUI *obj, void *data);
friend void RemoteStatusCB(BaseUI *obj, char *output, int rc);
friend void TurnOffHourGlass(BaseUI *obj, void *data);
friend void OpenClose(void *data, BaseUI *obj);
friend void ActionCB(void *data, BaseUI *obj, char *actionReferenceName);
friend void UpdatePrintJobs(BaseUI *obj, void *data);
friend void PreferenceCB(void *data, PreferenceRequest req, char *value);
friend void FilterCB(void *data);
friend void ModifyCB(void *data);
friend boolean SelectPrintJobs(BaseUI *obj);
friend void FindCB(void *data);
friend void AddQueues(BaseUI *obj, void *data);
friend void RestoreAppCB(BaseUI *obj, void *data);
private:
static void InitQueueDetails(BaseUI *obj, void *data);
static void RemoteStatusCB(BaseUI *obj, char *output, int rc);
static void TurnOffHourGlass(BaseUI *obj, void *data);
static void OpenClose(void *data, BaseUI *obj);
static void ActionCB(void *data, BaseUI *obj, char *actionReferenceName);
static void UpdatePrintJobs(BaseUI *obj, void *data);
static void PreferenceCB(void *data, PreferenceRequest req, char *value);
static void FilterCB(void *data);
static void ModifyCB(void *data);
static boolean SelectPrintJobs(BaseUI *obj);
static void FindCB(void *data);
static void AddQueues(BaseUI *obj, void *data);
static void RestoreAppCB(BaseUI *obj, void *data);
void OpenClose(BaseUI *obj);
void PreferenceCB(PreferenceRequest req, char *value);
void FilterCB(BaseUI *container);
void UpdateStatusLine();
void UpdateQueues();
void RestoreApp();
void AddActions(BaseObj *dummy);
void ShowStatusDialog(DtPrinterIcon *);
void HandleShowDetailsLabelPreferenceRequest(IconStyle style);
void HandleDetailsPreferenceRequest(boolean details_on);
boolean ShowUserJob(DtPrtJobIcon *_job, char *user_name);
void ShowUserJobs(BaseUI *queue, char *user_name, boolean flag);
void HandleShowOnlyMinePreferenceRequest(boolean flag);
int connect_timeout; // connect timeout to contact server
long Frequency;
char *old_dbsearchpath;
boolean save_state;
public:
int old_uid;
PrinterApplicationMode app_mode;
DtPrinterIcon *single_printer;
DtMainW *window;
char *printer_dir;
char *lang;
char *home;
DtApp(char *progname, int *argc, char **argv);
~DtApp();
void SaveYourSelf();
char *SessionFile();
char *SessionPath() { return printer_dir; }
char *GetBottomString(BaseObj *job, boolean need_details);
void ActionCB(BaseUI *obj, char *actionReferenceName);
};
#endif // DTAPP_H

View File

@@ -0,0 +1,86 @@
/* $TOG: DtDetailsLabel.C /main/3 1998/07/24 16:11:46 mgreess $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#include "DtDetailsLabel.h"
#include "Icon.h"
#include "WorkArea.h"
#include "dtprintinfomsg.h"
boolean DtDetailsLabel::first_time = true;
Pixmap DtDetailsLabel::blank_pixmap;
Pixmap DtDetailsLabel::blank_mask;
XmString DtDetailsLabel::bottom_label[2];
DtDetailsLabel::DtDetailsLabel(MotifUI *parent)
: MotifUI(parent, "Details", NULL)
{
if (first_time)
{
char *label = new char[strlen(MESSAGE(OwnerL)) + strlen(MESSAGE(SizeL)) +
strlen(MESSAGE(TimeL)) + strlen(MESSAGE(DateL)) +
strlen(MESSAGE(JobNumberL)) + 5];
sprintf(label, "%s\n%s\n%s\n%s", MESSAGE(SizeL),
MESSAGE(JobNumberL), MESSAGE(TimeL), MESSAGE(DateL));
bottom_label[0] = StringCreate(label);
sprintf(label, "%s\n%s\n%s\n%s\n%s",
MESSAGE(OwnerL), MESSAGE(SizeL),
MESSAGE(JobNumberL), MESSAGE(TimeL), MESSAGE(DateL));
bottom_label[1] = StringCreate(label);
Dimension highlight;
XtVaGetValues(parent->BaseWidget(),
XmNhighlightThickness, &highlight, NULL);
int height = 21 + 2 * highlight;
blank_pixmap = XCreatePixmap(display, root, 1, height, depth);
blank_mask = XCreatePixmap(display, root, 1, height, 1);
GC gc_mask = XCreateGC(display, blank_mask, 0, NULL);
XSetForeground(display, gc_mask, 0);
XFillRectangle(display, blank_mask, gc_mask, 0, 0, 1, height);
XFreeGC(display, gc_mask);
delete [] label;
first_time = false;
}
XmString top_string = StringCreate(MESSAGE(Position1L));
XmString label_string = StringCreate(MESSAGE(JobNameL));
Widget p = XtParent(parent->BaseWidget());
Pixel bg;
XtVaGetValues(p, XmNbackground, &bg, NULL);
_w = XtVaCreateManagedWidget("DtDetailsLabel", iconWidgetClass, p,
GuiNsuperNode, parent->BaseWidget(),
XmNalignment, XmALIGNMENT_END,
XmNtraversalOn, False,
XmNbackground, bg,
GuiNiconMarginThickness, 0,
XmNhighlightThickness, 0,
XmNlabelString, label_string,
GuiNtopLabelString, top_string,
XmNlabelPixmap, blank_pixmap,
GuiNiconMask, blank_mask,
GuiNpixmapPlacement, GuiPIXMAP_LEFT,
NULL);
StringFree(top_string);
StringFree(label_string);
XtAddCallback(_w, GuiNsingleClickCallback, &DtDetailsLabel::ClickCB, NULL);
XtAddCallback(_w, GuiNdoubleClickCallback, &DtDetailsLabel::ClickCB, NULL);
}
void DtDetailsLabel::Update(boolean show_only_my_jobs)
{
int i = 1;
if (show_only_my_jobs)
i = 0;
XtVaSetValues(_w, GuiNbottomLabelString, bottom_label[i], NULL);
}
void DtDetailsLabel::ClickCB(Widget w, XtPointer, XtPointer)
{
XtVaSetValues(w, GuiNselected, False, NULL);
}

View File

@@ -0,0 +1,32 @@
/* $XConsortium: DtDetailsLabel.h /main/3 1995/11/06 09:34:43 rswiston $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifndef DTDETAILSLABEL_H
#define DTDETAILSLABEL_H
#include "MotifUI.h"
class DtDetailsLabel : public MotifUI {
static void ClickCB(Widget, XtPointer, XtPointer);
static boolean first_time;
static XmString bottom_label[];
static Pixmap blank_pixmap;
static Pixmap blank_mask;
public:
DtDetailsLabel(MotifUI *parent);
void Update(boolean show_only_my_jobs);
const UI_Class UIClass() { return LABEL; }
const char *const UIClassName() { return "DtDetailsLabel"; }
};
#endif // DTDETAILSLABEL_H

View File

@@ -0,0 +1,637 @@
/* $TOG: DtFindD.C /main/5 1998/07/24 16:12:13 mgreess $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#include "DtFindD.h"
#include "DtMainW.h"
#include "DtApp.h"
#include "DtSetModList.h"
#include "DtWorkArea.h"
#include "Button.h"
#include "Prompt.h"
#include "LabelObj.h"
#include "Container.h"
#include "Sep.h"
#include "DtPrtJobIcon.h"
#include "dtprintinfomsg.h"
#include <unistd.h> // This is for the getuid function
DtJobList::DtJobList(AnyUI *parent)
: Container(parent, "found_container", SCROLLED_VERTICAL_ROW_COLUMN,
MULTIPLE_SELECT)
{
IconView(SMALL_ICON);
}
class _JobIcon : public IconObj
{
public:
DtPrtJobIcon *job_icon;
BaseUI *printer;
BaseUI *job_list;
_JobIcon(AnyUI *parent, DtPrtJobIcon *obj, IconFields);
};
_JobIcon::_JobIcon(AnyUI *parent, DtPrtJobIcon *obj, IconFields fields)
: IconObj(parent, (char *)obj->Name(), "DtPrtjb", NULL, NULL, NULL,
fields)
{
job_icon = obj;
job_list = obj->Parent();
printer = job_list->Parent();
}
void DtJobList::NotifySelected(BaseUI *obj)
{
Container::NotifySelected(obj);
int n_items;
Selection(&n_items);
DtFindD *findD = (DtFindD *) Parent();
if (n_items == 0)
{
findD->cancel_jobs->Active(false);
findD->goto_job->Active(false);
}
else
{
if (n_items == 1)
findD->goto_job->Active(true);
else
findD->goto_job->Active(false);
findD->cancel_jobs->Active(true);
}
}
DtFindD::DtFindD(MotifUI *parent,
char *name,
SelectProc select_proc)
: Dialog(parent, name)
{
_has_been_posted = false;
mainw = (DtMainW *) parent;
_select_proc = select_proc;
if (getuid() == 0) // check to see if we are root
prompt = new Prompt(this, MESSAGE(JobName1L));
else
prompt = new Prompt(this, MESSAGE(MyJobNameL));
prompt->AttachRight();
prompt->AttachLeft();
prompt->AttachTop();
Container *rc = new Container(this, "rc", HORIZONTAL_ROW_COLUMN,
MULTIPLE_SELECT);
if (getuid() == 0) // check to see if we are root
match_any_user = new Button(rc, MESSAGE(OnlyRootJobsL), TOGGLE_BUTTON);
else
match_any_user = NULL;
ignore_case = new Button(rc, MESSAGE(IgnoreCaseL), TOGGLE_BUTTON);
ignore_case->Selected(true);
exact_match = new Button(rc, MESSAGE(ExactMatchL), TOGGLE_BUTTON);
rc->AttachRight();
rc->AttachTop(prompt, 5);
Sep *sep = new Sep(this);
sep->AttachRight();
sep->AttachLeft();
sep->AttachTop(rc, 5);
field1 = new LabelObj(this, MESSAGE(JobName1L));
field1->AttachLeft(22);
field1->AttachTop(sep, 5);
field2 = new LabelObj(this, MESSAGE(PrinterL));
field2->AttachLeft(field1);
field2->AttachTop(sep, 5);
field3 = new LabelObj(this, MESSAGE(OwnerL));
field3->AttachLeft(field2);
field3->AttachTop(sep, 5);
field3->Visible(false);
field4 = new LabelObj(this, MESSAGE(PositionL));
field4->AttachLeft(field2);
field4->AttachRight();
field4->AttachTop(sep, 5);
Container *form = new Container(this, "form", FORM);
goto_job = new Button(form, MESSAGE(GotoL), PUSH_BUTTON, GotoCB, this);
goto_job->Active(false);
cancel_jobs = new Button(form, MESSAGE(CancelPrintJobsL), PUSH_BUTTON,
CancelJobsCB, this);
cancel_jobs->Active(false);
form->AttachBottom(5);
form->AttachRight();
form->AttachLeft();
goto_job->AttachBottom();
goto_job->AttachTop();
cancel_jobs->AttachBottom();
cancel_jobs->AttachTop();
found_container = new DtJobList(this);
found_container->AttachRight();
found_container->AttachLeft();
found_container->AttachBottom(form, 10);
found_container->AttachTop(field1);
start = new Button(this, MESSAGE(StartFindL), PUSH_BUTTON, StartCB, this);
stop = new Button(this, MESSAGE(StopFindL), PUSH_BUTTON, StopCB, this);
close_it = new Button(this, MESSAGE(CloseL), PUSH_BUTTON, CancelCB, this);
stop->Active(false);
help = new Button(this, MESSAGE(HelpL), PUSH_BUTTON, HelpCB, this);
DefaultButton(start);
CancelButton(close_it);
}
DtFindD::~DtFindD()
{
// Empty
}
boolean DtFindD::SetVisiblity(boolean flag)
{
if (_has_been_posted == false)
{
Dialog::SetVisiblity(flag);
Refresh();
int width = StringWidth(Name()) + 30;
if (width < 400)
width = 400;
if (Width() < width)
Width(width);
_has_been_posted = true;
int w1 = cancel_jobs->Width();
int w2 = goto_job->Width();
int offset = (width - (w1 + w2)) / 3;
goto_job->AttachLeft(offset);
cancel_jobs->AttachRight(offset);
cancel_jobs->AttachLeft(NULL, 0);
}
found_container->DeleteChildren();
cancel_jobs->Active(false);
goto_job->Active(false);
if (match_any_user)
{
match_any_user->Selected(false);
match_any_user->Active(mainw->setPrefD->ShowOnlyMyJobs() ? false : true);
}
Dialog::SetVisiblity(flag);
if (flag)
prompt->SetFocus();
return true;
}
void DtFindD::UpdateMatchAnyUser()
{
if (match_any_user)
match_any_user->Active(mainw->setPrefD->ShowOnlyMyJobs() ? false : true);
}
boolean DtFindD::MatchAnyUser()
{
if (match_any_user)
{
if (match_any_user->Active() == false)
return false;
else
return (match_any_user->Selected() ? false : true);
}
else
return false;
}
void DtFindD::Start()
{
_working = true;
mainw->in_find = true;
mainw->WorkingCursor(true);
stop->PointerShape(LEFT_SLANTED_ARROW_CURSOR);
help->PointerShape(LEFT_SLANTED_ARROW_CURSOR);
stop->Active(true);
DefaultButton(stop);
close_it->Active(false);
start->Active(false);
prompt->Active(false);
ignore_case->Active(false);
exact_match->Active(false);
found_container->DeleteChildren();
cancel_jobs->Active(false);
goto_job->Active(false);
if (match_any_user)
match_any_user->Active(false);
found_container->BeginUpdate();
_cur_obj = 0;
if (mainw->container->NumChildren())
{
BaseUI *icon = mainw->container->Children()[0];
_prev_visible = icon->Visible();
_prev_opened = icon->Open();
}
AddTimeOut(CheckQueue, NULL, 200);
}
void DtFindD::Cancel()
{
Visible(false);
Stop();
}
void DtFindD::Stop()
{
if (_cur_obj > mainw->container->NumChildren())
return;
_cur_obj = mainw->container->NumChildren() + 1;
found_container->EndUpdate();
start->Active(true);
DefaultButton(start);
stop->Active(false);
close_it->Active(true);
prompt->Active(true);
ignore_case->Active(true);
exact_match->Active(true);
prompt->SetFocus();
if (mainw->setModList && mainw->setModList->Visible())
mainw->setModList->Reset();
if (match_any_user)
match_any_user->Active(mainw->setPrefD->ShowOnlyMyJobs() ? false : true);
if (Visible())
{
int n_matches;
BaseUI **matches;
char *value1 = NULL;
char *value = prompt->Value();
if (!value || *value == '\0')
value = ".*";
else if (*value == '*')
{
value1 = new char[strlen(value) + 2];
sprintf(value1, ".%s", value);
value = value1;
}
mainw->container->FindByName(value, 0, &n_matches, &matches,
_select_proc,
exact_match->Selected() ? false : true,
ignore_case->Selected() ? false : true);
delete [] value1;
if (n_matches)
{
IconFields fields = new IconFieldsRec;
int n_fields, i, w;
if (MatchAnyUser())
n_fields = 3;
else
n_fields = 2;
fields->n_fields = n_fields;
fields->field_spacing = 20;
fields->fields = new char *[n_fields];
fields->fields_widths = new int[n_fields];
fields->alignments = new LabelType[n_fields];
fields->draw_fields = NULL;
fields->selected = NULL;
fields->active = NULL;
fields->name_width = StringWidth(MESSAGE(JobName1L));
fields->fields_widths[0] = StringWidth(MESSAGE(PrinterL));
fields->alignments[0] = LEFT_JUSTIFIED;
if (n_fields == 3)
{
fields->fields_widths[1] = StringWidth(MESSAGE(OwnerL));
fields->fields_widths[2] = StringWidth(MESSAGE(PositionL));
fields->alignments[1] = LEFT_JUSTIFIED;
fields->alignments[2] = RIGHT_JUSTIFIED;
if (field3->Visible() == false)
{
field3->Visible(true);
field4->AttachLeft(field3);
}
}
else
{
fields->alignments[1] = RIGHT_JUSTIFIED;
fields->fields_widths[1] = StringWidth(MESSAGE(PositionL));
if (field4->Visible())
{
field4->AttachLeft(field2);
field3->Visible(false);
}
}
for (i = 0; i < n_matches; i++)
{
DtPrtJobIcon *job = (DtPrtJobIcon *)matches[i];
if ((w = StringWidth(job->Name())) > fields->name_width)
fields->name_width = w;
w = StringWidth(job->Parent()->Parent()->Name());
if (w > fields->fields_widths[0])
fields->fields_widths[0] = w;
if (n_fields == 3)
{
char *s = job->PrintJobObj()->AttributeValue((char *)OWNER);
if ((w = StringWidth(s)) > fields->fields_widths[1])
fields->fields_widths[1] = w;
}
}
if (fields->name_width % 2)
fields->name_width += 1;
if (fields->fields_widths[0] % 2)
fields->fields_widths[0] += 1;
if (n_fields == 3)
{
if (fields->fields_widths[1] % 2)
fields->fields_widths[1] += 1;
if (fields->fields_widths[2] % 2)
fields->fields_widths[2] += 1;
}
else
{
if (fields->fields_widths[1] % 2)
fields->fields_widths[1] += 1;
}
field1->Width(fields->name_width + 20);
field2->Width(fields->fields_widths[0] + 20);
field3->Width(fields->fields_widths[1] + 20);
if (n_fields == 3)
field4->Width(fields->fields_widths[2] + 20);
for (i = 0; i < n_matches; i++)
{
DtPrtJobIcon *job = (DtPrtJobIcon *)matches[i];
char number[9];
sprintf(number, "%d", job->Order() + 1);
fields->fields[0] = (char *)job->Parent()->Parent()->Name();
if (n_fields == 3)
{
char *s = job->PrintJobObj()->AttributeValue((char *)OWNER);
fields->fields[1] = s;
fields->fields[2] = number;
}
else
fields->fields[1] = number;
_JobIcon *icon = new _JobIcon(found_container, job, fields);
}
delete []matches;
delete fields->fields;
delete fields->fields_widths;
delete fields->alignments;
delete fields;
}
else
new LabelObj(found_container, MESSAGE(NoMatchesL));
}
mainw->WorkingCursor(false);
_working = false;
mainw->in_find = false;
}
void DtFindD::UpdateQueue()
{
if (_cur_obj < mainw->container->NumChildren())
{
BaseUI *icon = mainw->container->Children()[_cur_obj];
char *message = new char[200];
sprintf(message, MESSAGE(SearchL), icon->Name());
found_container->UpdateMessage(message);
delete [] message;
icon->Visible(true);
DtPrinterIcon *icon1 = (DtPrinterIcon *)icon;
icon1->waitForChildren = true;
icon1->Open(true);
icon1->waitForChildren = false;
boolean no_children;
if (icon1->QueueObj()->NumChildren() == 0)
no_children = true;
else
{
int n_matches;
char *value1 = NULL;
char *value = prompt->Value();
if (!value || *value == '\0')
value = ".*";
else if (*value == '*')
{
value1 = new char[strlen(value) + 2];
sprintf(value1, ".%s", value);
value = value1;
}
icon1->FindByName(value, 0, &n_matches, NULL, _select_proc,
exact_match->Selected() ? false : true,
ignore_case->Selected() ? false : true);
delete value1;
if (n_matches)
no_children = false;
else
no_children = true;
}
if (no_children)
{
if (_prev_visible == false)
icon->Visible(false);
if (_prev_opened == false)
icon->Open(false);
}
_cur_obj++;
if (_cur_obj < mainw->container->NumChildren())
{
icon = mainw->container->Children()[_cur_obj];
_prev_visible = icon->Visible();
_prev_opened = icon->Open();
}
AddTimeOut(CheckQueue, NULL, 200);
}
else if (_cur_obj == mainw->container->NumChildren())
Stop();
}
boolean DtFindD::HandleHelpRequest()
{
mainw->DisplayHelp("FindDialogDE");
return true;
}
void DtFindD::CheckQueue(BaseUI *obj, void *)
{
((DtFindD *)obj)->UpdateQueue();
}
BaseUI *DtFindD::FindJob(BaseUI *obj)
{
int i;
BaseUI *job = ((_JobIcon *)obj)->job_icon;
BaseUI **children = ((_JobIcon *)obj)->job_list->Children();
int n_children = ((_JobIcon *)obj)->job_list->NumChildren();
for (i = 0; i < n_children; i++)
if (job == children[i])
return children[i];
Dialog *dialog = new Dialog(mainw, (char *) Name(),
MESSAGE(NotFoundMessageL), INFORMATION,
MESSAGE(OKL));
dialog->Visible(true);
return NULL;
}
void DtFindD::GotoCB(void *data)
{
DtFindD *obj = (DtFindD *) data;
BaseUI **selection;
int n_items;
obj->found_container->Selection(&n_items, &selection);
if (n_items == 1)
{
BaseUI *print_job = obj->FindJob(selection[0]);
if (print_job)
{
print_job->MakeVisible();
print_job->Selected(true);
}
}
delete []selection;
}
void DtFindD::CancelJobsCB(void *data)
{
DtFindD *obj = (DtFindD *) data;
extern void ActionCB(void *data, BaseUI *obj, char *actionReferenceName);
BaseUI **selection;
int n_items;
obj->found_container->Selection(&n_items, &selection);
if (n_items)
{
int i;
for (i = 0; i < n_items; i++)
{
BaseUI *print_job = obj->FindJob(selection[i]);
if (print_job)
{
DtApp *app = (DtApp *)obj->mainw->Parent();
app->ActionCB(print_job, (char *)CANCEL_PRINT_JOB);
}
}
}
delete []selection;
}
void DtFindD::CloseCB()
{
Cancel();
}
void DtFindD::CancelCB(void *data)
{
DtFindD *obj = (DtFindD *) data;
obj->Cancel();
}
void DtFindD::StartCB(void *data)
{
DtFindD *obj = (DtFindD *) data;
obj->Start();
}
void DtFindD::StopCB(void *data)
{
DtFindD *obj = (DtFindD *) data;
obj->_cur_obj = obj->mainw->container->NumChildren();
}
void DtFindD::HelpCB(void *data)
{
DtFindD *obj = (DtFindD *) data;
obj->HandleHelpRequest();
}
void DtFindD::DeleteJobFromList(BaseUI *obj)
{
int i;
int n_children = found_container->NumChildren();
_JobIcon **children = (_JobIcon **)found_container->Children();
for (i = 0; i < n_children; i++)
{
if (obj->Parent() == children[i]->job_list)
{
if (children[i]->job_icon == obj)
{
children[i]->Selected(false);
delete children[i];
return;
}
}
}
}
void DtFindD::UpdatePrinter(BaseUI *printer)
{
int n_children = found_container->NumChildren();
if (n_children == 0)
return;
_JobIcon **children = (_JobIcon **)found_container->Children();
int i, w1;
int width = StringWidth(MESSAGE(PrinterL));
BaseUI *last_printer = NULL;
for (i = 0; i < n_children; i++)
{
if (last_printer != children[i]->printer)
{
last_printer = children[i]->printer;
if ((w1 = StringWidth(last_printer->Name())) > width)
width = w1;
}
}
if (width % 2)
width += 1;
// Create a widget and resize it to the desired width, then resize the
// row column to the width + margin space. I have to do this because
// the row column widget does not resize itself correctly.
Dimension wid;
XtVaGetValues(found_container->InnerWidget(), XmNwidth, &wid, NULL);
wid -= field2->Width();
wid += width;
new LabelObj(found_container, " ");
children = (_JobIcon **)found_container->Children();
children[n_children]->Order(0);
n_children++;
children[0]->Width((int)wid);
wid += 6;
XtVaSetValues(found_container->InnerWidget(), XmNwidth, (int)wid, NULL);
field2->Width(width + 20);
for (i = 1; i < n_children; i++)
{
if (printer == children[i]->printer)
children[i]->Field(0, (char *)printer->Name(), width);
else
children[i]->Field(0, NULL, width);
}
delete children[0];
}
void DtFindD::UpdatePositions(BaseUI *printer)
{
if (mainw->in_find)
return;
int n_children = found_container->NumChildren();
if (n_children == 0)
return;
_JobIcon **children = (_JobIcon **)found_container->Children();
int i, index = children[0]->NumberFields() - 1;
for (i = 0; i < n_children; i++)
{
if (printer == children[i]->printer)
children[i]->Field(index, children[i]->job_icon->TopString(), 0);
}
}

View File

@@ -0,0 +1,107 @@
/* $XConsortium: DtFindD.h /main/3 1995/11/06 09:35:06 rswiston $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifndef DTFINDD_H
#define DTFINDD_H
#include "Dialog.h"
#include "Container.h"
class Button;
class LabelObj;
class Prompt;
class Container;
class DtMainW;
class DtFindD;
class DtJobList : public Container
{
private:
DtFindD *findD;
void NotifySelected(BaseUI *obj);
public:
DtJobList(AnyUI *parent);
};
class DtFindD : public Dialog {
friend class DtJobList;
friend void StartCB(void *);
friend void StopCB(void *);
friend void CancelCB(void *);
friend void GotoCB(void *);
friend void CancelJobsCB(void *);
friend void HelpCB(void *);
friend void CheckQueue(BaseUI *, void *);
private:
boolean _has_been_posted;
int _cur_obj;
DtMainW *mainw;
// dialog buttons
Button *start;
Button *stop;
Button *close_it;
Button *help;
Button *cancel_jobs;
Button *goto_job;
Button *ignore_case;
Button *exact_match;
Button *match_any_user;
DtJobList *found_container;
LabelObj *field1;
LabelObj *field2;
LabelObj *field3;
LabelObj *field4;
Prompt *prompt;
SelectProc _select_proc;
boolean _working;
boolean _prev_opened;
boolean _prev_visible;
static void StartCB(void *);
static void StopCB(void *);
static void CancelCB(void *);
static void GotoCB(void *);
static void CancelJobsCB(void *);
static void HelpCB(void *);
static void CheckQueue(BaseUI *, void *);
boolean SetVisiblity(boolean flag);
void CloseCB();
void Cancel();
void Stop();
void Start();
void UpdateQueue();
BaseUI *FindJob(BaseUI *obj);
boolean HandleHelpRequest();
public:
DtFindD(AnyUI *parent, char *name, SelectProc select_proc);
boolean Working() { return _working; }
boolean MatchAnyUser();
void UpdateMatchAnyUser();
void DeleteJobFromList(BaseUI *);
void UpdatePrinter(BaseUI *printer);
void UpdatePositions(BaseUI *printer);
virtual ~DtFindD();
};
#endif /* DTFINDD_H */

View File

@@ -0,0 +1,323 @@
/* $TOG: DtFindSet.C /main/5 1998/07/24 16:12:36 mgreess $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#include "DtFindSet.h"
#include "DtPrtProps.h"
#include "DtMainW.h"
#include "Button.h"
#include "Container.h"
#include "IconObj.h"
#include "LabelObj.h"
#include "ComboBoxObj.h"
#include "HelpSystem.h"
#include "Invoke.h"
#include "dtprintinfomsg.h"
#include <stdio.h>
#include <pwd.h>
#include <unistd.h> // This is for the getuid function
#include <stdlib.h> // This is for the getenv function
const char *GET_DIRS =
"lang=${LANG:-C} ; "
"for i in $(echo $XMICONSEARCHPATH | sed -e 's/:/ /g' -e s/%L/$lang/g) ; "
"do "
"dirname $i ; "
"done | sort -u";
// Subclass IconObj in order to disable SetOpen method
class FindSetIcon : public IconObj
{
public:
FindSetIcon(AnyUI *parent, char *name, char *icon) :
IconObj(parent, name, icon) { }
boolean SetOpen(boolean) { return true; }
};
DtFindSet::DtFindSet(DtMainW *parent, char *name, CallerCallback _callback)
: Dialog(parent, name, MODAL)
{
mainw = parent;
callback = _callback;
last_position = -1;
helpSystem = NULL;
char *output;
Invoke *_thread = new Invoke(GET_DIRS, &output);
char *s, *s1 = output;
s = s1;
n_dirs = 0;
while (s && (s = strchr(s1, '\n')))
{
n_dirs++;
s1 = s + 1;
}
if (_thread->status || n_dirs == 0)
{
delete [] output;
struct passwd * pwInfo;
char *home = getenv("HOME");
if (home == NULL || strlen(home) == 0)
{
pwInfo = getpwuid(getuid());
home = pwInfo->pw_dir;
}
output = new char[strlen(home) + 80];
n_dirs = 3;
sprintf(output, "%s/.dt/icons\n"
"/usr/dt/appconfig/icons/C\n"
"/etc/dt/appconfig/icons/C\n", (home[1] ? home : "" ));
}
dirs = new char *[n_dirs];
filenames = new FileNames [n_dirs];
s = output;
int i;
for (i = 0; i < n_dirs; i++)
{
s1 = s;
s = strchr(s, '\n');
*s++ = '\0';
dirs[i] = strdup(s1);
filenames[i] = new FileNamesStruct;
filenames[i]->icons = NULL;
filenames[i]->read_it = true;
filenames[i]->n_icons = 0;
}
delete [] output;
delete _thread;
comboBox = new ComboBoxObj(this, ComboBoxCB, MESSAGE(IconFoldersL), dirs,
n_dirs);
icon_label = new LabelObj(this, MESSAGE(IconTitleL));
icons = new Container(this, "icons", SCROLLED_WORK_AREA);
icons->Height(250);
empty = new LabelObj(icons, MESSAGE(EmptyL));
empty->Visible(false);
comboBox->AttachTop(5);
comboBox->AttachLeft();
comboBox->AttachRight();
icon_label->AttachTop(comboBox, 10);
icon_label->AttachLeft();
icon_label->AttachRight();
icons->AttachTop(icon_label);
icons->AttachRight();
icons->AttachLeft();
icons->AttachBottom();
ok = new Button(this, MESSAGE(OKL), PUSH_BUTTON, OkCB, this);
cancel = new Button(this, MESSAGE(CancelL), PUSH_BUTTON, CancelCB, this);
help = new Button(this, MESSAGE(HelpL), PUSH_BUTTON, HelpCB, this);
DefaultButton(ok);
CancelButton(cancel);
}
DtFindSet::~DtFindSet()
{
int i;
for (i = 0; i < n_dirs; i++)
{
delete dirs[i];
delete filenames[i];
}
delete []dirs;
delete []filenames;
}
void DtFindSet::InitComboBox(BaseUI *obj, void * /*data*/)
{
DtFindSet *findSet = (DtFindSet *)obj;
findSet->Refresh();
ComboBoxCB(findSet->comboBox, findSet->dirs[0], 1);
}
boolean DtFindSet::SetVisiblity(boolean flag)
{
if (last_position == -1)
AddTimeOut(&DtFindSet::InitComboBox, NULL, 1000);
Dialog::SetVisiblity(flag);
return true;
}
void DtFindSet::Reset()
{
}
void DtFindSet::Apply()
{
BaseUI **items;
int n_items;
icons->Selection(&n_items, &items);
if (n_items && callback)
{
FindSetIcon *icon = (FindSetIcon *)items[0];
char *iconfile;
if (iconfile = strrchr(icon->IconFile(), '/'))
iconfile++;
else
iconfile = icon->IconFile();
(*callback)(caller, iconfile);
}
delete []items;
}
void DtFindSet::CloseCB()
{
Reset();
Visible(false);
}
void DtFindSet::OkCB(void *data)
{
DtFindSet *obj = (DtFindSet *) data;
obj->Apply();
obj->Visible(false);
}
void DtFindSet::ApplyCB(void *data)
{
DtFindSet *obj = (DtFindSet *) data;
obj->Apply();
}
void DtFindSet::CancelCB(void *data)
{
DtFindSet *obj = (DtFindSet *) data;
obj->Reset();
obj->Visible(false);
}
void DtFindSet::ResetCB(void *data)
{
DtFindSet *obj = (DtFindSet *) data;
obj->Reset();
}
void DtFindSet::HelpCB(void *data)
{
DtFindSet *obj = (DtFindSet *) data;
obj->HandleHelpRequest();
}
boolean DtFindSet::HandleHelpRequest()
{
char old_msg[200];
strcpy(old_msg, mainw->status_line->Name());
mainw->status_line->Name(MESSAGE(GettingHelpL));
mainw->WorkingCursor(true);
if (!helpSystem)
{
char *title = new char[120];
sprintf(title, "%s - %s", mainw->Name(), MESSAGE(HelpL));
helpSystem = new HelpSystem(this, title, "Printmgr", "FindSetDE",
QUICK_HELP);
helpSystem->Visible(true);
delete [] title;
}
else
{
helpSystem->Visible(true);
helpSystem->Refresh();
helpSystem->HelpVolume("Printmgr", "FindSetDE");
}
mainw->status_line->Name(old_msg);
mainw->WorkingCursor(false);
return true;
}
void DtFindSet::ComboBoxCB(ComboBoxObj *obj, char *dir, int position)
{
DtFindSet *findSet = (DtFindSet *)obj->Parent();
if (findSet->last_position == position)
return;
FileNames filenames;
int i;
char *buf = new char[400]; // This allows for a directory len of 240 bytes
findSet->PointerShape(HOUR_GLASS_CURSOR);
findSet->icons->BeginUpdate();
findSet->icons->SelectAll(false);
if (findSet->last_position > 0)
{
filenames = findSet->filenames[findSet->last_position - 1];
FindSetIcon **icon = filenames->icons;
for (i = 0; i < filenames->n_icons; i++, icon++)
(*icon)->Visible(false);
}
filenames = findSet->filenames[position - 1];
if (filenames->read_it)
{
sprintf(buf, "cd %s 2> /dev/null ; "
"/bin/ls -1 | grep '\\.l\\.pm$' | "
"sed 's/\\.l\\.pm//g' | "
"while read file ; do "
"if [ -f $file.m.pm -a -f $file.t.pm ] ; "
"then echo $file ; fi ; "
"done", dir);
char *output;
Invoke *_thread = new Invoke(buf, &output);
char *s, *s1 = output;
s = s1;
filenames->n_icons = 0;
while (s && (s = strchr(s1, '\n')))
{
filenames->n_icons++;
s1 = s + 1;
}
if (filenames->n_icons)
{
s = output;
filenames->icons = new FindSetIcon*[filenames->n_icons];
for (i = 0; i < filenames->n_icons; i++)
{
s1 = s;
s = strchr(s, '\n');
*s++ = '\0';
if (!(i % 10))
{
sprintf(buf, MESSAGE(LoadingIconsL), i, filenames->n_icons);
findSet->icons->UpdateMessage(buf);
}
sprintf(buf, "%s/%s", dir, s1);
filenames->icons[i] = new FindSetIcon(findSet->icons, s1, buf);
}
}
delete _thread;
delete output;
filenames->read_it = false;
}
else
{
FindSetIcon **icon = filenames->icons;
for (i = 0; i < filenames->n_icons; i++, icon++)
(*icon)->Visible(true);
}
findSet->PointerShape(LEFT_SLANTED_ARROW_CURSOR);
findSet->icons->EndUpdate();
sprintf(buf, MESSAGE(IconTitleL), filenames->n_icons);
findSet->icon_label->Name(buf);
if (filenames->n_icons)
findSet->empty->Visible(false);
else
findSet->empty->Visible(true);
findSet->last_position = position;
delete [] buf;
}

View File

@@ -0,0 +1,88 @@
/* $XConsortium: DtFindSet.h /main/3 1995/11/06 09:35:17 rswiston $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifndef DTFINDSET_H
#define DTFINDSET_H
#include "Dialog.h"
#include "Prompt.h"
class Button;
class DtMainW;
class LabelObj;
class Container;
class ComboBoxObj;
class FindSetIcon;
class HelpSystem;
typedef void (*CallerCallback)(BaseUI *caller, char *iconFile);
typedef struct
{
boolean read_it;
FindSetIcon **icons;
int n_icons;
} FileNamesStruct, *FileNames, **FileNamesList;
class DtFindSet : public Dialog {
friend void OkCB(void *data);
friend void ApplyCB(void *data);
friend void CancelCB(void *data);
friend void ResetCB(void *data);
friend void HelpCB(void *data);
friend void ComboBoxCB(ComboBoxObj *, char *, int);
friend void InitComboBox(BaseUI *, void *data);
static void OkCB(void *data);
static void ApplyCB(void *data);
static void CancelCB(void *data);
static void ResetCB(void *data);
static void HelpCB(void *data);
static void ComboBoxCB(ComboBoxObj *, char *, int);
static void InitComboBox(BaseUI *, void *data);
private:
DtMainW *mainw;
HelpSystem *helpSystem;
// dialog buttons
Button *ok;
Button *apply;
Button *cancel;
Button *reset;
Button *help;
char **dirs;
int n_dirs;
int last_position;
BaseUI *caller;
CallerCallback callback;
FileNamesList filenames;
ComboBoxObj *comboBox;
Container *icons;
LabelObj *empty;
LabelObj *icon_label;
boolean _has_been_posted;
void CloseCB();
boolean SetVisiblity(boolean);
boolean HandleHelpRequest();
public:
DtFindSet(DtMainW *, char *name, CallerCallback callback);
~DtFindSet();
void Caller(BaseUI *obj) { caller = obj; }
void Apply();
void Reset();
};
#endif // DTFINDSET_H

View File

@@ -0,0 +1,348 @@
/* $TOG: DtMainW.C /main/5 1998/07/24 16:12:56 mgreess $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#include "DtMainW.h"
#include "Application.h"
#include "Menu.h"
#include "MenuBar.h"
#include "LabelObj.h"
#include "Sep.h"
#include "Button.h"
#include "IconObj.h"
#include "DtWorkArea.h"
#include "DtActions.h"
#include "DtSetModList.h"
#include "DtFindD.h"
#include "HelpSystem.h"
#include "BaseObj.h"
#include "dtprintinfomsg.h"
#include <stdlib.h>
#include <stdio.h>
static char *GetIcon(AnyUI *obj, PrinterApplicationMode app_mode)
{
if (app_mode == SINGLE_PRINTER)
{
if (obj->depth == 1)
return "Fpprnt.l.bm";
else
return "Fpprnt.l.pm";
}
else
{
if (obj->depth == 1)
return "FpPrtmg.l.bm";
else
return "FpPrtmg.l.pm";
}
}
DtMainW::DtMainW(char *category,
AnyUI *p,
char *name,
ContainerType container_type,
SelectionType select_type,
OpenCallback openCB,
void *openCallbackData,
PreferenceCallback prefCB,
void *prefCallbackData,
char *fileMenuName,
char *fileMenuMnemonic,
PrinterApplicationMode _app_mode)
: MainWindow(category, p, name, name, GetIcon(p, _app_mode))
{
Visible(true);
in_find = false;
working_curs = 0;
app_mode = _app_mode;
_openClose = openCB;
_prefCB = prefCB;
if (openCallbackData)
_openCallbackData = openCallbackData;
else
_openCallbackData = this;
if (prefCallbackData)
_prefCallbackData = prefCallbackData;
else
_prefCallbackData = this;
_fileMenuName = fileMenuName;
_fileMenuMnemonic = fileMenuMnemonic;
_container_type = container_type;
_select_type = select_type;
setModList = NULL;
setPrefD = NULL;
findD = NULL;
helpSystem = NULL;
findSetD = NULL;
action_data = (ActionData **) malloc(sizeof(ActionData *));
n_action_data = 0;
}
DtMainW::~DtMainW()
{
int i;
for (i = 0; i < n_action_data; i++)
{
delete action_data[i]->actionReferenceName;
delete action_data[i];
}
delete action_data;
}
void DtMainW::DisplayHelp(char *location_id, char *volume)
{
char old_msg[200];
strcpy(old_msg, status_line->Name());
status_line->Name(MESSAGE(GettingHelpL));
WorkingCursor(true);
if (!helpSystem)
{
char *title = new char[120];
sprintf(title, "%s - %s", Name(), MESSAGE(HelpL));
helpSystem = new HelpSystem(this, title, volume, location_id);
helpSystem->Visible(true);
delete [] title;
}
else
{
helpSystem->Visible(true);
helpSystem->Refresh();
helpSystem->HelpVolume(volume, location_id);
}
status_line->Name(old_msg);
WorkingCursor(false);
helpSystem->ToFront();
}
void DtMainW::Initialize()
{
mbar = new MenuBar(this);
Container *form = new DtWorkArea((char *) Category(), this, (char *)Name(),
FORM);
container = new DtWorkArea((char *) Category(), form, (char *)Name(),
_container_type, _select_type);
status_line = new LabelObj(form, " ", LEFT_JUSTIFIED, true);
status_line->AttachBottom();
status_line->AttachLeft();
status_line->AttachRight();
container->AttachTop();
container->AttachLeft();
container->AttachRight();
container->AttachBottom(status_line);
if (app_mode == SINGLE_PRINTER)
container->WidthHeight(600, 150);
else
container->WidthHeight(600, 400);
SetWorkWindow(form);
char *title = new char[100];
sprintf(title, MESSAGE(SetOptionsTitleL), Name());
setPrefD = new DtSetPref(this, title, container, _prefCB,
_prefCallbackData);
delete [] title;
fileMenu = new DtMenu(mbar, _fileMenuName, _fileMenuMnemonic,
"PrinterMenuDE");
exitB = new Button(fileMenu, MESSAGE(ExitChoiceL), PUSH_BUTTON, ExitCB, this,
MESSAGE(ExitMnemonicL), MESSAGE(ExitAcceleratorL));
actionsMenu = new DtActions(mbar, MESSAGE(SelectedMenuL),
MESSAGE(SelectedAcceleratorL));
actionsMenu->Active(false);
if (app_mode != CONFIG_PRINTERS)
{
viewMenu = new DtMenu(mbar, MESSAGE(ViewMenuL),
MESSAGE(ViewAcceleratorL), "ViewMenuDE");
setPref = new Button(viewMenu, MESSAGE(SetOptionsChoiceL), PUSH_BUTTON,
SetPrefCB, setPrefD, MESSAGE(SetOptionsMnemonicL));
}
else
viewMenu = NULL;
helpMenu = new DtMenu(mbar, MESSAGE(HelpChoiceL), MESSAGE(HelpMnemonicL),
"HelpMenuDE");
introduction = new Button(helpMenu, MESSAGE(OverviewChoiceL), PUSH_BUTTON,
HelpCB, this, MESSAGE(OverviewMnemonicL));
new Sep(helpMenu);
tasks = new Button(helpMenu, MESSAGE(TaskChoiceL), PUSH_BUTTON, TasksCB,
this, MESSAGE(TaskMnemonicL));
reference = new Button(helpMenu, MESSAGE(ReferenceChoiceL), PUSH_BUTTON,
ReferenceCB, this, MESSAGE(ReferenceMnemonicL));
onWindow = new Button(helpMenu, MESSAGE(OnItemChoiceL), PUSH_BUTTON,
OnItemCB, this, MESSAGE(OnItemMnemonicL));
new Sep(helpMenu);
usingHelp = new Button(helpMenu, MESSAGE(UsingHelpChoiceL), PUSH_BUTTON,
UsingHelpCB, this, MESSAGE(UsingHelpMnemonicL));
new Sep(helpMenu);
char *tmp;
if (app_mode == PRINT_MANAGER)
tmp = MESSAGE(AboutChoice1L);
else if (app_mode == SINGLE_PRINTER)
tmp = MESSAGE(AboutChoice2L);
else
tmp = MESSAGE(AboutChoice3L);
version = new Button(helpMenu, tmp, PUSH_BUTTON, AboutCB,
this, MESSAGE(AboutMnemonicL));
mbar->SetHelpMenu(helpMenu);
}
void DtMainW::SetPrefCB(void *data)
{
DtSetPref *obj = (DtSetPref *) data;
obj->Visible(true);
}
void DtMainW::ExitCB(void *data)
{
Application *app = (Application *)((BaseUI *)data)->Parent();
app->SaveMe();
delete (BaseObj *)((BaseUI *)data)->ApplicationData;
delete ((BaseUI *)data)->Parent();
exit (0);
}
void DtMainW::OpenClose(BaseUI *obj)
{
if (_openClose)
(*_openClose)(_openCallbackData, obj);
}
void DtMainW::DtAddAction(char *name, char *category, char *actionName,
ActionCallback callback, void *callback_data,
char *mnemonic, char *acceleratorText,
char *accelerator)
{
BaseUI *action1;
if (action1 = actionsMenu->FindByName(name))
action1->Category(NULL);
else
actionsMenu->AddAction(name, category, actionName, callback,
callback_data, mnemonic, acceleratorText,
accelerator);
int size = sizeof(ActionData *) * (n_action_data + 1);
action_data = (ActionData **) realloc(action_data, size);
action_data[n_action_data] = (ActionData *)malloc(sizeof(ActionData));
action_data[n_action_data]->actionReferenceName = strdup(actionName);
action_data[n_action_data]->callback_data = callback_data;
action_data[n_action_data]->actionCallback = callback;
Button *action = AddAction(name, category, &DtMainW::ActionCB, NULL,
mnemonic, acceleratorText, accelerator);
action->ApplicationData = action_data[n_action_data];
n_action_data++;
}
void DtMainW::DtAddSep(char *category)
{
actionsMenu->AddSep(category);
AddSep(category);
}
void DtMainW::ActionCB(void *callback_data)
{
Button *action = (Button *) callback_data;
DtMainW *window = (DtMainW *)action->Parent()->Parent()->Parent();
ActionData *cb = (ActionData *) action->ApplicationData;
if (cb->actionCallback)
{
if (window->container->ObjectExists(window->PopupObjectUniqueID))
{
(*cb->actionCallback)(cb->callback_data, window->PopupObject,
cb->actionReferenceName);
}
else
{
Dialog *dialog = new Dialog(window, (char *)window->Name(),
MESSAGE(NotFoundMessageL), INFORMATION,
MESSAGE(OKL));
dialog->Visible(true);
}
}
}
void DtMainW::HelpCB(void *data)
{
DtMainW * obj = (DtMainW *) data;
obj->DisplayHelp("_hometopic");
}
void DtMainW::ReferenceCB(void *data)
{
DtMainW * obj = (DtMainW *) data;
obj->DisplayHelp("Reference");
}
void DtMainW::TasksCB(void *data)
{
DtMainW * obj = (DtMainW *) data;
obj->DisplayHelp("Tasks");
}
void DtMainW::UsingHelpCB(void *data)
{
DtMainW * obj = (DtMainW *) data;
obj->DisplayHelp("_hometopic", "Help4Help");
}
void DtMainW::AboutCB(void *data)
{
DtMainW * obj = (DtMainW *) data;
obj->DisplayHelp("_copyright");
}
void DtMainW::OnItemCB(void *data)
{
DtMainW * obj = (DtMainW *) data;
obj->ContextualHelp();
}
boolean DtMainW::HandleHelpRequest()
{
if (app_mode == PRINT_MANAGER)
DisplayHelp("MainWindowDE");
else
DisplayHelp("PJMainWindowDE");
return true;
}
void DtMainW::WorkingCursor(boolean flag)
{
int i;
BaseUI **children = Children();
if (flag)
{
if (working_curs == 0)
for (i = 0; i < NumChildren(); i++, children++)
(*children)->PointerShape(HOUR_GLASS_CURSOR);
working_curs++;
}
else
{
working_curs--;
if (working_curs == 0)
for (i = 0; i < NumChildren(); i++, children++)
(*children)->PointerShape(LEFT_SLANTED_ARROW_CURSOR);
}
}
boolean DtMenu::HandleHelpRequest()
{
((DtMainW *)Parent()->Parent())->DisplayHelp(location_id);
return true;
}

View File

@@ -0,0 +1,144 @@
/* $XConsortium: DtMainW.h /main/3 1995/11/06 09:35:41 rswiston $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifndef DTMAINW_H
#define DTMAINW_H
#include "MainWindow.h"
#include "Menu.h"
#include "MenuBar.h"
#include "DtActions.h"
#include "DtSetPref.h"
#include "DtPrinterIcon.h"
class Button;
class DtSetModList;
class DtWorkArea;
class DtFindD;
class LabelObj;
class HelpSystem;
class DtFindSet;
typedef void (*OpenCallback) (void *callback_data, BaseUI *object);
typedef struct
{
ActionCallback actionCallback;
void *callback_data;
char *actionReferenceName;
} ActionData;
class DtMenu : public Menu
{
public:
char *location_id;
DtMenu(MenuBar *parent, char *name, char *mnemonic, char *help_location_id) :
Menu(parent, name, mnemonic)
{
location_id = help_location_id;
}
boolean HandleHelpRequest();
};
class DtMainW : public MainWindow
{
friend void SetPrefCB(void *data);
friend void ExitCB(void *data);
friend void ActionCB(void *data);
friend void HelpCB(void *data);
friend void ReferenceCB(void *data);
friend void UsingHelpCB(void *data);
friend void TasksCB(void *data);
friend void AboutCB(void *data);
private:
OpenCallback _openClose;
PreferenceCallback _prefCB;
ContainerType _container_type;
SelectionType _select_type;
void *_openCallbackData;
void *_prefCallbackData;
char *_fileMenuName;
char *_fileMenuMnemonic;
ActionData **action_data;
int n_action_data;
int working_curs;
PrinterApplicationMode app_mode;
static void SetPrefCB(void *data);
static void ExitCB(void *data);
static void ActionCB(void *data);
static void OnItemCB(void *data);
static void HelpCB(void *data);
static void ReferenceCB(void *data);
static void UsingHelpCB(void *data);
static void TasksCB(void *data);
static void AboutCB(void *data);
boolean HandleHelpRequest();
public:
DtFindD * findD; // Find dialog
DtSetPref * setPrefD; // Set preferences dialog
DtSetModList *setModList; // Set printer list dialog
DtWorkArea * container; // Work Area
MenuBar * mbar; // Menu Bar
HelpSystem * helpSystem;
DtFindSet * findSetD;
// Pulldown menu structure
DtMenu *fileMenu;
Button *exitB;
DtMenu *viewMenu;
Button *setPref;
DtActions *actionsMenu;
DtMenu *helpMenu;
Button *introduction;
// ------------------- Separator
Button *tasks;
Button *reference;
Button *onWindow;
// ------------------- Separator
Button *usingHelp;
// ------------------- Separator
Button *version;
LabelObj *status_line;
boolean in_find;
DtMainW(char *category,
AnyUI *p,
char *name,
ContainerType container_type = SCROLLED_WORK_AREA,
SelectionType select_type = SINGLE_SELECT,
OpenCallback openCB = NULL,
void *openCallbackData = NULL,
PreferenceCallback prefCB = NULL,
void *prefCallbackData = NULL,
char *fileMenuName = NULL,
char *fileMenuMnemonic = NULL,
PrinterApplicationMode app_mode = SINGLE_PRINTER);
~DtMainW();
void DtAddAction(char *name, char *category,
char *actionReferenceName, ActionCallback callback,
void *callback_data, char *mnemonic = NULL,
char *acceleratorText = NULL, char *accelerator = NULL);
void WorkingCursor(boolean);
PrinterApplicationMode PrinterAppMode() { return app_mode; }
void DisplayHelp(char *location_id, char *volume = "Printmgr");
void DtAddSep(char *category);
void Initialize();
void OpenClose(BaseUI *obj);
};
#endif /* DTMAINW_H */

View File

@@ -0,0 +1,763 @@
/* $TOG: DtPrinterIcon.C /main/5 1998/07/24 16:13:14 mgreess $ */
#include "DtPrinterIcon.h"
#include "Button.h"
#include "DtMainW.h"
#include "Prompt.h"
#include "DtPrtProps.h"
#include "DtSetModList.h"
#include "DtFindD.h"
#include "DtDetailsLabel.h"
#include "Dt/Action.h"
#include <sys/stat.h>
#include <time.h>
#include <fcntl.h>
#include <unistd.h> // This is for the getuid function
#include <stdlib.h> // This is for the getenv function
#include <pwd.h>
#include "dtprintinfomsg.h"
const char *PROPS_PRINTER_ID = "PrinterPropsDE";
const char *PRINTER_ID = "PrinterDE";
const char *STATUS_FLAG = "Flag";
const char *PRINTER_ICON_FILE = "Fpprnt";
const char *PRINTERS_PERSONAL_DIR = ".dt/.Printers";
char DtPrinterIcon::homeDir[300] = "";
DtPrinterIcon::DtPrinterIcon(DtMainW *mainW, AnyUI *parent, Queue *que,
PrinterApplicationMode _app_mode)
: IconObj((char *) que->ObjectClassName(), parent,
GetPrinterLabel(que->Name(), _app_mode),
GetPrinterIcon(que->Name(), _app_mode))
{
app_mode = _app_mode;
queue = que;
status = NULL;
dnd = NULL;
#ifdef aix
_print_device_up = NULL;
#endif
// Return if initializing printers
if (app_mode == INITIALIZE_PRINTERS)
return;
char *buf = new char[300];
struct stat statbuff;
if (*homeDir == '\0')
{
struct passwd * pwInfo;
char *home = getenv("HOME");
if (home == NULL || strlen(home) == 0)
{
pwInfo = getpwuid(getuid());
home = pwInfo->pw_dir;
}
strcpy(homeDir, home);
sprintf(buf, "%s/%s", homeDir, PRINTERS_PERSONAL_DIR);
if (stat(buf, &statbuff) < 0)
{
sprintf(buf, "mkdir -p %s/%s", homeDir, PRINTERS_PERSONAL_DIR);
system(buf);
}
sprintf(buf, "%s/.dt/types", homeDir);
if (stat(buf, &statbuff) < 0)
{
sprintf(buf, "mkdir -p %s/.dt/types", homeDir);
system(buf);
}
DtDbReloadNotify(&DtPrinterIcon::ReloadNotifyCB, this);
}
sprintf(buf, "%s/%s/%s_Print", homeDir, PRINTERS_PERSONAL_DIR,
queue->Name());
if (stat(buf, &statbuff) < 0)
{
int fd = creat(buf, 0755);
close(fd);
}
else if (statbuff.st_mode != 0755)
chmod(buf, 0755);
mainw = mainW;
props = NULL;
container = NULL;
waitForChildren = false;
if (app_mode == PRINT_MANAGER)
expand = new Button(this, queue->DisplayName(), PUSH_BUTTON, OpenCloseCB,
NULL, NULL, NULL, NULL, "Dtplus");
else
expand = NULL;
if (app_mode != CONFIG_PRINTERS)
{
#ifdef aix
n_devices = queue->NumberDevices();
_print_device_up = new boolean[n_devices];
int i;
for (i = 0; i < n_devices; i++)
_print_device_up[i] = true;
#else
queue->ReadAttributes();
_print_device_up = true;
#endif
_print_queue_up = true;
flag = new IconObj((char *)STATUS_FLAG, this, NULL, "DtFlag");
flag->Visible(false);
details_label = new DtDetailsLabel(this);
_previous_show_only_my_jobs = mainw->setPrefD->ShowOnlyMyJobs() ?
false : true;
ShowDetailsLabel(IconView(), false);
}
else
{
flag = NULL;
details_label = NULL;
}
dnd = new DtDND(this, DndCB);
mainw->RegisterPopup(this);
ApplicationData = NULL;
if (app_mode == SINGLE_PRINTER)
{
mainw->IconName((char *)Name());
char *iconFile = GetPrinterIcon(que->Name(), _app_mode);
char *s = new char [strlen(iconFile) + 6];
if (depth == 1)
sprintf(s, "%s.l.bm", iconFile);
else
sprintf(s, "%s.l.pm", iconFile);
mainw->IconFile(s);
if (!mainw->IconFile())
{
*(s + strlen(iconFile) + 1) = 'm';
mainw->IconFile(s);
}
delete [] s;
}
delete [] buf;
}
DtPrinterIcon::~DtPrinterIcon()
{
delete dnd;
#ifdef aix
delete _print_device_up;
#endif
delete status;
}
char *DtPrinterIcon::Description()
{
static char buf[200];
sprintf(buf, "%s_Print", queue->Name());
char *desc = DtActionDescription(buf);
return (desc ? desc : "");
}
void DtPrinterIcon::PrintQueueUp(boolean _flag)
{
if (app_mode == CONFIG_PRINTERS)
return;
if (props)
status[0]->Value(_flag ? MESSAGE(UpL) : MESSAGE(DownL));
_print_queue_up = _flag;
ShowFlag();
}
#ifdef aix
void DtPrinterIcon::PrintDeviceUp(boolean _flag, int index)
{
if (app_mode == CONFIG_PRINTERS)
return;
if (index >= 0 && index < n_devices)
{
if (props)
status[index + 1]->Value(_flag ? MESSAGE(UpL) : MESSAGE(DownL));
_print_device_up[index] = _flag;
ShowFlag();
}
}
boolean DtPrinterIcon::PrintDeviceUp(int index)
{
if (app_mode != CONFIG_PRINTERS)
{
if (index >= 0 && index < n_devices)
return _print_device_up[index];
}
return false;
}
#else
void DtPrinterIcon::PrintDeviceUp(boolean _flag)
{
if (app_mode == CONFIG_PRINTERS)
return;
if (props)
status[1]->Value(_flag ? MESSAGE(UpL) : MESSAGE(DownL));
_print_device_up = _flag;
ShowFlag();
}
#endif
boolean DtPrinterIcon::SetName(char *_name)
{
IconObj::SetName(_name);
if (dnd)
dnd->UpdateRects();
return true;
}
boolean DtPrinterIcon::SetOpen(boolean _flag)
{
if (app_mode != CONFIG_PRINTERS)
IconObj::SetOpen(_flag);
return true;
}
DtPrinterContainer *DtPrinterIcon::CreateContainer()
{
if (!container)
{
container = new DtPrinterContainer((char *)Category(), this,
queue->DisplayName());
mainw->RegisterPopup(container);
container->dnd = new DtDND(container, DndCB);
container->ApplicationData = queue;
ApplicationData = container;
}
return container;
}
char *DtPrinterIcon::CreateActionFile()
{
static char filename[300];
FILE *fp;
struct stat statbuff;
boolean create_file;
char *buf = new char[300];
char *lang = getenv("LANG");
if (!(lang && *lang))
lang = "C";
if (app_mode == INITIALIZE_PRINTERS || app_mode == CONFIG_PRINTERS)
{
sprintf(filename, "/etc/dt/appconfig/types/%s", lang);
if (stat(filename, &statbuff) < 0)
{
sprintf(buf, "mkdir -p %s", filename);
system(buf);
}
sprintf(filename, "/etc/dt/appconfig/types/%s/%s.dt", lang,
queue->Name());
if (stat(filename, &statbuff) < 0 || statbuff.st_size == 0)
create_file = true;
else
create_file = false;
}
else
{
sprintf(buf, "%s/.dt/types/%s.dt", homeDir, queue->Name());
if (stat(buf, &statbuff) < 0 || statbuff.st_size == 0)
{
sprintf(buf, "/etc/dt/appconfig/types/%s/%s.dt", lang, queue->Name());
if (stat(buf, &statbuff) >= 0 && statbuff.st_size > 0)
{
sprintf(buf, "cp /etc/dt/appconfig/types/%s/%s.dt %s/.dt/types",
lang, queue->Name(), homeDir);
system(buf);
create_file = false;
}
else
create_file = true;
}
else
create_file = false;
sprintf(filename, "%s/.dt/types/%s.dt", homeDir, queue->Name());
}
if (create_file)
{
if (fp = fopen(filename, "w"))
{
time_t secs;
time(&secs);
fprintf(fp, "################################################################\n\n");
fprintf(fp, "# Actions and Datatypes for Printer \"%s\"\n\n", queue->Name());
fprintf(fp, "# Common Desktop Environment 1.0\n\n");
fprintf(fp, "# This file was created by the \"dtprintinfo\" program.\n\n");
strftime(buf, 300, "%c", localtime(&secs));
fprintf(fp, "# Date of creation: %s\n\n", buf);
fprintf(fp, "################################################################\n\n");
fprintf(fp, "ACTION %s_Print\n", queue->Name());
fprintf(fp, "{\n");
fprintf(fp, " ARG_TYPE *\n");
fprintf(fp, " LABEL %s\n", queue->Name());
fprintf(fp, " ICON %s\n", PRINTER_ICON_FILE);
fprintf(fp, " TYPE COMMAND\n");
fprintf(fp, " WINDOW_TYPE NO_STDIO\n");
fprintf(fp, " EXEC_STRING env LPDEST=%s \\\n", queue->Name());
fprintf(fp, " /usr/dt/bin/dtaction Print %%(File)Arg_1%%\n");
sprintf(buf, MESSAGE(DefaultDescriptionL), queue->Name());
fprintf(fp, " DESCRIPTION %s\n", buf);
fprintf(fp, "}\n\n");
fprintf(fp, "ACTION %s_Print\n", queue->Name());
fprintf(fp, "{\n");
fprintf(fp, " ARG_COUNT 0\n");
fprintf(fp, " TYPE COMMAND\n");
fprintf(fp, " WINDOW_TYPE NO_STDIO\n");
fprintf(fp, " EXEC_STRING /usr/dt/bin/dtaction Dtprintinfo %s\n", queue->Name());
fprintf(fp, "}\n");
fflush(fp);
fclose(fp);
chmod(filename, 0644);
}
}
delete [] buf;
return filename;
}
void DtPrinterIcon::DndCB(BaseUI *obj, char **value, int * /*len*/,
DNDProtocol dndProtocol)
{
DtPrinterIcon *printer;
if (obj->UIClass() == ICON)
printer = (DtPrinterIcon *)obj;
else
printer = (DtPrinterIcon *)obj->Parent();
DtActionArg ap[1];
char *old_LPDEST = NULL;
ap[0].argClass = DtACTION_FILE;
char *buf = new char[100];
switch (dndProtocol)
{
case FILENAME_TRANSFER: // Dropping an Object on a printer
ap[0].u.file.name = *value;
if (printer->PrintActionExists())
sprintf(buf, "%s_Print", printer->queue->Name());
else
{
if (old_LPDEST = STRDUP(getenv("LPDEST")))
{
sprintf(buf, "LPDEST=%s", printer->queue->Name());
putenv(buf);
}
strcpy(buf, "Print");
}
DtActionInvoke(((AnyUI *)printer->mainw->Parent())->BaseWidget(), buf, ap,
1, NULL, NULL, NULL, True, NULL, NULL);
if (old_LPDEST)
{
sprintf(buf, "LPDEST=%s", old_LPDEST);
putenv(buf);
delete old_LPDEST;
}
break;
case CONVERT_DATA: // Dragging a printer to an object
if (printer->PrintActionExists())
{
struct stat statbuff;
*value = new char[strlen(homeDir) + strlen(PRINTERS_PERSONAL_DIR) +
strlen(printer->queue->Name()) + 10];
sprintf(*value, "%s/%s/%s_Print", homeDir, PRINTERS_PERSONAL_DIR,
printer->queue->Name());
if (stat(*value, &statbuff) < 0)
{
int fd = creat(*value, 0755);
close(fd);
}
}
else
*value = NULL;
break;
case DROP_ON_ROOT:
{
char *x = *value;
char *y = strchr(x, '\n');
*y++ = '\0';
char *filename = strchr(y, '\n');
*filename++ = '\0';
char *work_space = strchr(filename, '\n');
if (work_space)
*work_space++ = '\0';
}
break;
case TEXT_TRANSFER:
break;
case BUFFER_TRANSFER:
*value = new char[strlen(printer->queue->Name()) + 10];
sprintf(*value, "%s_Print", printer->queue->Name());
break;
case CONVERT_DELETE:
break;
case ANIMATE:
break;
}
delete [] buf;
}
boolean DtPrinterIcon::SetIcon(IconStyle style)
{
IconObj::SetIcon(style);
if (dnd)
dnd->UpdateRects();
ShowDetailsLabel(style, Visible());
return true;
}
boolean DtPrinterIcon::HandleHelpRequest()
{
mainw->DisplayHelp((char *)PRINTER_ID);
return true;
}
void DtPrinterIcon::UpdateExpand()
{
if (expand)
{
if (Open() == true)
expand->IconFile("Dtminus");
else
expand->IconFile("Dtplus");
}
ShowDetailsLabel(IconView(), true);
}
void DtPrinterIcon::Update()
{
char *cmd = new char[200];
sprintf(cmd, GET_QUEUE_STATUS, queue->Name());
Invoke *_thread = new Invoke(cmd);
PrintQueueUp(_thread->status ? false : true);
delete _thread;
#ifdef aix
int i;
for (i = 0; i < n_devices; i++)
{
sprintf(cmd, GET_DEVICE_STATUS, queue->Device(i));
_thread = new Invoke(cmd);
PrintDeviceUp(_thread->status ? false : true, i);
delete _thread;
}
#else
#ifdef sun
if (queue->IsRemote())
PrintDeviceUp(_print_queue_up);
else
{
sprintf(cmd, GET_DEVICE_STATUS, queue->Name());
_thread = new Invoke(cmd);
PrintDeviceUp(_thread->status ? false : true);
delete _thread;
}
#else
sprintf(cmd, GET_DEVICE_STATUS, queue->Name());
_thread = new Invoke(cmd);
PrintDeviceUp(_thread->status ? false : true);
delete _thread;
#endif
#endif
delete [] cmd;
}
void DtPrinterIcon::ShowFlag()
{
if (app_mode == CONFIG_PRINTERS)
return;
if (Visible() == false || mainw->setPrefD->ShowStatusFlags() == false)
{
flag->Visible(false);
return;
}
// Update problem flag's visiblity
#ifdef aix
boolean show_it;
if (_print_queue_up)
{
int i;
show_it = false;
for (i = 0; i < n_devices; i++)
if (_print_device_up[i] == false)
{
show_it = true;
break;
}
}
else
show_it = true;
flag->Visible(show_it);
#else
if (_print_queue_up && _print_device_up)
flag->Visible(false);
else
flag->Visible(true);
#endif
}
void DtPrinterIcon::NotifyVisiblity(BaseUI *obj)
{
if (app_mode == CONFIG_PRINTERS)
return;
if (obj == flag)
{
boolean show_it = Visible();
if (show_it)
{
if (mainw->setPrefD->ShowStatusFlags() == false)
show_it = false;
else
{
#ifdef aix
if (_print_queue_up)
{
show_it = false;
int i;
for (i = 0; i < n_devices; i++)
if (_print_device_up[i] == false)
{
show_it = true;
break;
}
}
else
show_it = true;
#else
if (_print_queue_up && _print_device_up)
show_it = false;
else
show_it = true;
#endif
}
}
if (flag->Visible() != show_it)
flag->Visible(show_it);
}
else if (obj == details_label)
{
boolean show_it = Visible();
if (show_it)
{
if (container && IconView() == DETAILS && Open())
{
if (container->NumChildren() == 0 ||
(container->Children()[0])->UIClass() == LABEL)
show_it = false;
else if (mainw->setPrefD->ShowDetailsLabel())
{
show_it = false;
int i;
BaseUI **children = container->Children();
for (i = 0; i < container->NumChildren(); i++)
if (children[i]->Visible())
{
show_it = true;
break;
}
}
else
show_it = mainw->setPrefD->ShowDetailsLabel();
}
else
show_it = false;
}
if (details_label->Visible() != show_it)
details_label->Visible(show_it);
}
}
void DtPrinterIcon::ShowDetailsLabel(IconStyle style, boolean is_visible)
{
if (app_mode == CONFIG_PRINTERS)
return;
if (_previous_show_only_my_jobs != mainw->setPrefD->ShowOnlyMyJobs())
{
_previous_show_only_my_jobs = mainw->setPrefD->ShowOnlyMyJobs();
details_label->Update(_previous_show_only_my_jobs);
}
if (container && style == DETAILS && is_visible && Open())
{
if (container->NumChildren() == 0 ||
(container->Children()[0])->UIClass() == LABEL)
details_label->Visible(false);
else if (mainw->setPrefD->ShowDetailsLabel())
{
boolean show_it = false;
int i;
BaseUI **children = container->Children();
for (i = 0; i < container->NumChildren(); i++)
if (children[i]->Visible())
{
show_it = true;
break;
}
details_label->Visible(show_it);
}
else
details_label->Visible(false);
}
else
details_label->Visible(false);
}
boolean DtPrinterIcon::SetVisiblity(boolean _flag)
{
if (_flag)
{
IconObj::SetVisiblity(_flag);
Update();
if (container && Open())
container->Visible(true);
ShowDetailsLabel(IconView(), _flag);
}
else
{
if (container)
{
container->Visible(false);
if (mainw->findD)
{
int i;
BaseUI **children = container->Children();
for (i = 0; i < container->NumChildren(); i++)
mainw->findD->DeleteJobFromList(children[i]);
}
}
IconObj::SetVisiblity(_flag);
}
if (dnd)
dnd->UpdateActivity(_flag);
return true;
}
void DtPrinterIcon::DisplayProps()
{
if (!props)
{
char *title = new char[200];
sprintf(title, MESSAGE(PrinterPropsTitleL), mainw->Name());
queue->ReadAttributes();
props = new DtPrtProps(mainw, title, this);
int n_matches = 0;
props->FindByName(MESSAGE(PrinterStatusL), 0, &n_matches,
(BaseUI***)&status);
delete [] title;
}
props->Visible(true);
}
void DtPrinterIcon::ReloadNotifyCB(XtPointer data)
{
DtPrinterIcon *printer = (DtPrinterIcon *)data;
DtDbLoad();
int i, n_siblings = printer->NumSiblings();
BaseUI **siblings = printer->Siblings();
for (i = 0; i < n_siblings; i++)
{
printer = (DtPrinterIcon *)siblings[i];
char *iconName = GetPrinterLabel(printer->queue->Name(),
printer->app_mode);
char *iconFile = GetPrinterIcon(printer->queue->Name(),
printer->app_mode);
if (strcmp(iconName, printer->Name()))
{
printer->Name(iconName);
if (printer->PrinterAppMode() == SINGLE_PRINTER)
printer->mainw->IconName(iconName);
if (printer->PrinterAppMode() == PRINT_MANAGER)
{
if (printer->mainw->findD && printer->mainw->findD->Visible())
printer->mainw->findD->UpdatePrinter(printer);
}
}
if (strcmp(iconFile, printer->IconFile()))
{
printer->IconFile(iconFile);
if (printer->PrinterAppMode() == SINGLE_PRINTER &&
iconFile && *iconFile)
{
char *s = new char [strlen(iconFile) + 6];
if (depth == 1)
sprintf(s, "%s.l.bm", iconFile);
else
sprintf(s, "%s.l.pm", iconFile);
printer->mainw->IconFile(s);
delete [] s;
}
}
if (printer->props && printer->props->Visible())
printer->props->Reset();
}
if (printer->mainw->setModList && printer->mainw->setModList->Visible())
printer->mainw->setModList->Reset();
}
void DtPrinterIcon::OpenCloseCB(void *data)
{
BaseUI *obj = ((BaseUI *)data)->Parent();
if (obj->Open())
obj->Open(false);
else
obj->Open(true);
}
boolean DtPrinterIcon::PrintActionExists()
{
boolean b;
char *buf = new char[60];
sprintf(buf, "%s_Print", queue->Name());
b = (DtActionExists(buf) ? true : false);
delete [] buf;
return b;
}
char *DtPrinterIcon::GetPrinterIcon(const char *printer,
PrinterApplicationMode _app_mode)
{
static char buf[200];
sprintf(buf, "%s_Print", printer);
if (_app_mode != INITIALIZE_PRINTERS && DtActionExists(buf))
{
char *iconfile = DtActionIcon(buf);
if (iconfile)
strcpy(buf, iconfile);
else
strcpy(buf, PRINTER_ICON_FILE);
}
else
strcpy(buf, PRINTER_ICON_FILE);
return buf;
}
char *DtPrinterIcon::GetPrinterLabel(const char *printer,
PrinterApplicationMode _app_mode)
{
static char buf[200];
sprintf(buf, "%s_Print", printer);
if (_app_mode != INITIALIZE_PRINTERS && DtActionExists(buf))
{
char *label = DtActionLabel(buf);
if (label)
strcpy(buf, label);
else
strcpy(buf, printer);
}
else
strcpy(buf, printer);
return buf;
}

View File

@@ -0,0 +1,127 @@
/* $XConsortium: DtPrinterIcon.h /main/3 1995/11/06 09:36:06 rswiston $ */
#ifndef DTPRINTERICON_H
#define DTPRINTERICON_H
#include "IconObj.h"
#include "Queue.h"
#include "Container.h"
#include "DtDND.h"
extern const char *PROPS_PRINTER_ID;
extern const char *PRINTER_ID;
extern const char *STATUS_FLAG;
extern const char *PRINTER_ICON_FILE;
typedef enum
{
SINGLE_PRINTER,
PRINT_MANAGER,
CONFIG_PRINTERS,
INITIALIZE_PRINTERS
} PrinterApplicationMode;
class DtMainW;
class DtPrtProps;
class IconObj;
class Container;
class Button;
class DtDetailsLabel;
class Prompt;
class DtPrinterContainer : public Container
{
public:
DtDND *dnd;
DtPrinterContainer(char *category, AnyUI *parent, char *name)
: Container(category, parent, name, SCROLLED_HORIZONTAL_ROW_COLUMN) { }
~DtPrinterContainer() { delete dnd; }
boolean DtPrinterContainer::SetVisiblity(boolean flag)
{
Container::SetVisiblity(flag);
dnd->UpdateActivity(flag);
return true;
}
};
class DtPrinterIcon : public IconObj
{
friend void DndCB(BaseUI *, char **, int *, DNDProtocol);
friend void OpenCloseCB(void *);
friend void AddPrintActionCB(BaseUI *, void *);
friend void ReloadNotifyCB(void *);
friend char * GetPrinterIcon(const char *, PrinterApplicationMode);
friend char * GetPrinterLabel(const char *, PrinterApplicationMode);
static void DndCB(BaseUI *, char **, int *, DNDProtocol);
static void OpenCloseCB(void *);
static void AddPrintActionCB(BaseUI *, void *);
static void ReloadNotifyCB(void *);
static char * GetPrinterIcon(const char *, PrinterApplicationMode);
static char * GetPrinterLabel(const char *, PrinterApplicationMode);
private:
static char homeDir[];
DtMainW *mainw;
DtDND *dnd;
Queue *queue;
Button *expand;
IconObj *flag;
DtDetailsLabel *details_label;
DtPrinterContainer *container;
DtPrtProps *props;
boolean _previous_show_only_my_jobs;
PrinterApplicationMode app_mode;
boolean _print_queue_up;
Prompt **status;
#ifdef aix
boolean *_print_device_up;
int n_devices;
#else
boolean _print_device_up;
#endif
void ShowFlag();
boolean SetVisiblity(boolean);
void NotifyVisiblity(BaseUI *);
boolean HandleHelpRequest();
boolean SetIcon(IconStyle);
boolean SetOpen(boolean);
boolean SetName(char *name);
public:
boolean updating;
boolean waitForChildren;
DtPrinterIcon(DtMainW *, AnyUI *parent, Queue *queue,
PrinterApplicationMode app_mode = SINGLE_PRINTER);
~DtPrinterIcon();
void DisplayProps();
void Update();
void UpdateExpand();
void PrintQueueUp(boolean);
boolean PrintQueueUp() { return _print_queue_up; }
#ifdef aix
void PrintDeviceUp(boolean, int index = 0);
boolean PrintDeviceUp(int index = 0);
#else
void PrintDeviceUp(boolean);
boolean PrintDeviceUp() { return _print_device_up; }
#endif
void ShowDetailsLabel(IconStyle, boolean is_visible);
char *CreateActionFile();
char *Description();
boolean PrintActionExists();
DtPrinterContainer *JobContainer() { return container; }
DtPrinterContainer *CreateContainer();
PrinterApplicationMode PrinterAppMode() { return app_mode; }
const char *HomeDir() { return homeDir; }
Queue *QueueObj() { return queue; }
};
#endif // DTPRINTERICON_H

View File

@@ -0,0 +1,146 @@
/* $XConsortium: DtProps.C /main/2 1995/07/17 14:03:51 drk $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#include "DtProps.h"
#include "DtMainW.h"
#include "Button.h"
#include "Prompt.h"
#include "LabelObj.h"
#include "Container.h"
#include "BaseObj.h"
#include "dtprintinfomsg.h"
#include <stdio.h>
DtProps::DtProps(AnyUI *parent,
char *name,
char *location_id,
boolean editable,
int n_attributes,
Attribute **attributes)
: Dialog(parent, name)
{
mainw = (DtMainW *) parent;
_location_id = location_id;
_has_been_posted = false;
rc = new Container(this, "rc", VERTICAL_ROW_COLUMN);
int i, captionWidth = 0, width, columns = 0;
for (i = 0; i < n_attributes; i++)
{
if ((width = StringWidth(attributes[i]->DisplayName)) > captionWidth)
captionWidth = width;
if ((width = strlen(attributes[i]->DisplayValue)) > columns)
columns = width;
}
for (i = 0; i < n_attributes; i++)
{
boolean _editable;
if (EditableAfterCreate(attributes[i]))
_editable = true;
else
_editable = false;
if (attributes[i]->ValueListType == INFORMATION_LINE)
new LabelObj(rc, attributes[i]->DisplayName);
else
new Prompt(rc, attributes[i]->DisplayName, _editable, STRING_PROMPT,
attributes[i]->DisplayValue, NULL,
NULL, true, columns, 1, captionWidth + 8);
}
ok = new Button(this, MESSAGE(OKL), PUSH_BUTTON, OkCB, this);
if (editable)
{
cancel = new Button(this, MESSAGE(CancelL), PUSH_BUTTON, CancelCB, this);
CancelButton(cancel);
}
else
CancelButton(ok);
help = new Button(this, MESSAGE(HelpL), PUSH_BUTTON, HelpCB, this);
rc->AttachAll();
DefaultButton(ok);
}
DtProps::~DtProps()
{
// Empty
}
boolean DtProps::SetVisiblity(boolean flag)
{
if (_has_been_posted == false)
{
Dialog::SetVisiblity(flag);
Refresh();
int width = StringWidth(Name()) + 35;
if (Width() < width)
{
Dialog::SetVisiblity(flag);
Width(width);
}
_has_been_posted = true;
}
Dialog::SetVisiblity(flag);
return true;
}
void DtProps::Reset()
{
}
void DtProps::Apply()
{
}
void DtProps::CloseCB()
{
Reset();
Visible(false);
}
void DtProps::OkCB(void *data)
{
DtProps *obj = (DtProps *) data;
obj->Apply();
obj->Visible(false);
}
void DtProps::ApplyCB(void *data)
{
DtProps *obj = (DtProps *) data;
obj->Apply();
}
void DtProps::CancelCB(void *data)
{
DtProps *obj = (DtProps *) data;
obj->Reset();
obj->Visible(false);
}
void DtProps::ResetCB(void *data)
{
DtProps *obj = (DtProps *) data;
obj->Reset();
}
void DtProps::HelpCB(void *data)
{
DtProps *obj = (DtProps *) data;
obj->HandleHelpRequest();
}
boolean DtProps::HandleHelpRequest()
{
mainw->DisplayHelp(_location_id);
return true;
}

View File

@@ -0,0 +1,66 @@
/* $XConsortium: DtProps.h /main/3 1995/11/06 09:36:21 rswiston $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifndef DTPROPS_H
#define DTPROPS_H
#include "Dialog.h"
#include "BaseObj.h"
class Button;
class Container;
class Prompt;
class DtMainW;
class DtProps : public Dialog {
friend void OkCB(void *data);
friend void ApplyCB(void *data);
friend void CancelCB(void *data);
friend void ResetCB(void *data);
friend void HelpCB(void *data);
static void OkCB(void *data);
static void ApplyCB(void *data);
static void CancelCB(void *data);
static void ResetCB(void *data);
static void HelpCB(void *data);
private:
DtMainW *mainw;
// dialog buttons
Button *ok;
Button *apply;
Button *cancel;
Button *reset;
Button *help;
Container *rc;
char *_location_id;
boolean _has_been_posted;
void CloseCB();
boolean SetVisiblity(boolean);
boolean HandleHelpRequest();
public:
DtProps(AnyUI *parent,
char *name,
char *location_id,
boolean editable,
int n_attrs,
Attribute **attrs);
virtual ~DtProps();
void Apply();
void Reset();
};
#endif // DTPROPS_H

View File

@@ -0,0 +1,98 @@
/* $TOG: DtPrtJobIcon.C /main/4 1998/07/24 16:13:33 mgreess $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#include "DtPrtJobIcon.h"
#include "DtApp.h"
#include "DtMainW.h"
#include "DtProps.h"
#include "DtFindD.h"
const char *PRINTJOB_ID = "PrintJobDE";
const char *PROPS_PRINTJOB_ID = "PrintJobPropsDE";
static char *GetBotString(DtMainW *mainW, BaseUI *parent, PrintJob *job)
{
boolean need_details = (parent->IconView() == DETAILS ? true : false);
DtApp *app = (DtApp *)mainW->Parent();
return app->GetBottomString(job, need_details);
}
static char *GetTopString(int seq_num)
{
static char number[9];
sprintf(number, "%d", seq_num);
return number;
}
DtPrtJobIcon::DtPrtJobIcon(DtMainW *mainW, AnyUI *parent, PrintJob *job,
int seq_num)
: IconObj((char *) job->ObjectClassName(), parent, job->DisplayName(),
"DtPrtjb", NULL, GetTopString(seq_num),
GetBotString(mainW, parent, job))
{
mainw = mainW;
mainw->RegisterPopup(this);
ApplicationData = job;
strcpy(job_number, job->AttributeValue((char *)JOB_NUMBER));
print_job = job;
props = NULL;
}
DtPrtJobIcon::~DtPrtJobIcon()
{
if (Selected())
Selected(false);
if (mainw->findD)
mainw->findD->DeleteJobFromList(this);
delete props;
}
boolean DtPrtJobIcon::HandleHelpRequest()
{
mainw->DisplayHelp((char *)PRINTJOB_ID);
return true;
}
void DtPrtJobIcon::DisplayProps()
{
if (!props)
{
char *title = new char[200];
sprintf(title, MESSAGE(PrintJobPropsTitleL), mainw->Name());
props = new DtProps(mainw, title, (char *) PROPS_PRINTJOB_ID, false,
print_job->NumAttributes(),
print_job->Attributes());
delete [] title;
}
props->Visible(true);
props->ToFront();
}
void DtPrtJobIcon::PrintJobObj(PrintJob *job)
{
ApplicationData = job;
print_job = job;
if (strcmp(job_number, job->AttributeValue((char *)JOB_NUMBER)))
{
Name(job->DisplayName());
BottomString(GetBotString(mainw, Parent(), job));
strcpy(job_number, job->AttributeValue((char *)JOB_NUMBER));
if (props)
{
props->Visible(false);
delete props;
props = NULL;
DisplayProps();
}
}
}
void DtPrtJobIcon::NotifyVisiblity(BaseUI * /*obj*/)
{
// Empty
}

View File

@@ -0,0 +1,44 @@
/* $XConsortium: DtPrtJobIcon.h /main/3 1995/11/06 09:36:33 rswiston $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifndef DTPRTJOBICON_H
#define DTPRTJOBICON_H
#include "IconObj.h"
#include "PrintJob.h"
class DtMainW;
class DtProps;
extern const char *PROPS_PRINTJOB_ID;
extern const char *PRINTJOB_ID;
class DtPrtJobIcon : public IconObj
{
DtMainW *mainw;
DtProps *props;
PrintJob *print_job;
char job_number[10];
boolean HandleHelpRequest();
void NotifyVisiblity(BaseUI *);
public:
DtPrtJobIcon(DtMainW *, AnyUI *parent, PrintJob *printJob,
int SequenceNumber);
~DtPrtJobIcon();
void DisplayProps();
void PrintJobObj(PrintJob *printJob);
PrintJob *PrintJobObj() { return print_job; }
const char *JobNumber() { return job_number; }
};
#endif // DTPRTJOBICON_H

View File

@@ -0,0 +1,319 @@
/* $TOG: DtPrtProps.C /main/4 1998/07/24 16:14:02 mgreess $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#include "DtPrtProps.h"
#include "DtFindSet.h"
#include "DtMainW.h"
#include "DtPrinterIcon.h"
#include "Button.h"
#include "Container.h"
#include "Group.h"
#include "IconObj.h"
#include "LabelObj.h"
#include "Sep.h"
#include "Dt/Action.h"
#include "dtprintinfomsg.h"
#include <stdio.h>
#include <unistd.h> // This is for the getpid function
#include <stdlib.h> // This is for the getenv function
DtPrtProps::DtPrtProps(DtMainW *parent, char *name, DtPrinterIcon *_printer)
: Dialog(parent, name)
{
mainw = parent;
printer = _printer;
_iconFile = STRDUP(printer->IconFile());
findSetD = NULL;
_has_been_posted = false;
int i, captionWidth = 0, width, columns = 0;
int n_attributes = printer->QueueObj()->NumAttributes();
Attribute **attributes = printer->QueueObj()->Attributes();
if ((width = StringWidth(MESSAGE(IconLabelL))) > captionWidth)
captionWidth = width;
if ((width = StringWidth(MESSAGE(IconGroupTitleL))) > captionWidth)
captionWidth = width;
if ((width = StringWidth(MESSAGE(DescriptionL))) > captionWidth)
captionWidth = width;
if ((width = strlen(printer->Name())) > columns)
columns = width;
for (i = 0; i < n_attributes; i++)
{
if ((width = StringWidth(attributes[i]->DisplayName)) > captionWidth)
captionWidth = width;
if ((width = strlen(attributes[i]->DisplayValue)) > columns)
columns = width;
}
icon_prompt = new Prompt(this, MESSAGE(IconLabelL), true, STRING_PROMPT,
(char *)printer->Name(), NULL,
NULL, true, columns, 1, captionWidth + 8);
icon_prompt->AttachLeft();
icon_prompt->AttachRight();
icon_prompt->AttachTop(5);
Container *form = new Container(this, "form", FORM);
icon_group = new Group(form, NULL, FORM_BOX);
LabelObj *label = new LabelObj(form, MESSAGE(IconGroupTitleL),
RIGHT_JUSTIFIED);
label->AttachTop();
label->AttachBottom();
label->AttachLeft();
label->Width(captionWidth + 8);
icon_group->AttachTop();
icon_group->AttachBottom();
icon_group->AttachRight();
icon_group->AttachLeft(label);
// Creation of Large Icon
largeIcon = new IconObj(icon_group, NULL, printer->IconFile());
largeIcon->IconView(VERY_LARGE_ICON);
largeIcon->AttachLeft(10);
largeIcon->AttachTop(10);
largeIcon->AttachBottom(10);
// Creation of Medium Icon
mediumIcon = new IconObj(icon_group, NULL, printer->IconFile());
mediumIcon->IconView(MEDIUM_ICON);
mediumIcon->AttachLeft(largeIcon, 10);
mediumIcon->AttachBottom(10);
// Creation of Small Icon
smallIcon = new IconObj(icon_group, NULL, printer->IconFile());
smallIcon->IconView(SMALL_ICON);
smallIcon->AttachLeft(mediumIcon, 10);
smallIcon->AttachBottom(10);
// Creation of Find Set Button
find_set = new Button(icon_group, MESSAGE(FindSetL), PUSH_BUTTON, FindSetCB,
this);
find_set->AttachRight(10);
find_set->AttachLeft(smallIcon, 10);
find_set->AttachBottom(10);
form->AttachLeft();
form->AttachRight();
form->AttachTop(icon_prompt, 5);
Container *rc = new Container(this, "rc", VERTICAL_ROW_COLUMN);
for (i = 0; i < n_attributes; i++)
{
new Prompt(rc, attributes[i]->DisplayName, false, STRING_PROMPT,
attributes[i]->DisplayValue, NULL,
NULL, true, columns, 1, captionWidth + 8);
if (mainw->PrinterAppMode() != CONFIG_PRINTERS)
{
char *value;
if (i == 0)
value = _printer->PrintQueueUp() ? MESSAGE(UpL) : MESSAGE(DownL);
else
#ifdef aix
value = _printer->PrintDeviceUp(i - 1) ? MESSAGE(UpL) :
MESSAGE(DownL);
#else
value = _printer->PrintDeviceUp() ? MESSAGE(UpL) : MESSAGE(DownL);
#endif
new Prompt(rc, MESSAGE(PrinterStatusL), false, STRING_PROMPT,
value, NULL, NULL, true, columns, 1, captionWidth + 8);
}
}
rc->AttachRight();
rc->AttachLeft();
rc->AttachBottom();
Sep *sep = new Sep(this);
sep->AttachRight();
sep->AttachLeft();
sep->AttachBottom(rc, 5);
description = new Prompt(this, MESSAGE(DescriptionL), false,
MULTI_LINE_STRING_PROMPT, printer->Description(),
NULL, NULL, true, columns, 3, captionWidth + 8);
description->AttachLeft();
description->AttachRight();
description->AttachTop(form, 5);
description->AttachBottom(sep, 5);
ok = new Button(this, MESSAGE(OKL), PUSH_BUTTON, OkCB, this);
cancel = new Button(this, MESSAGE(CancelL), PUSH_BUTTON, CancelCB, this);
help = new Button(this, MESSAGE(HelpL), PUSH_BUTTON, HelpCB, this);
DefaultButton(ok);
CancelButton(cancel);
}
DtPrtProps::~DtPrtProps()
{
delete _iconFile;
}
boolean DtPrtProps::SetVisiblity(boolean flag)
{
Dialog::SetVisiblity(flag);
if (_has_been_posted == false)
{
_has_been_posted = true;
find_set->Height(find_set->Height() + 6);
}
else if (flag)
Reset();
return true;
}
void DtPrtProps::Reset()
{
if (strcmp(printer->IconFile(), _iconFile))
SetActionIcons(printer->IconFile());
icon_prompt->Value((char *)printer->Name());
description->Value(printer->Description());
}
void DtPrtProps::Apply()
{
char *buf;
int buf_len;
char *iconName = (char *)IconLabel();
char *iconFile = (char *)IconFileName();
if (!iconName || *iconName == '\0')
iconName = (char *)printer->Name();
if (!iconFile || *iconFile == '\0')
iconFile = (char *)PRINTER_ICON_FILE;
if (!strcmp(iconName, printer->Name()) &&
!strcmp(iconFile, printer->IconFile()))
{
// return since nothing changed
return;
}
char *save_msg = strdup(mainw->status_line->Name());
mainw->WorkingCursor(true);
mainw->status_line->Name(MESSAGE(UpdatingActionsL));
Refresh();
buf_len = strlen(printer->QueueObj()->Name()) +
(2 * strlen(printer->HomeDir())) + 50;
if (buf_len < 200)
buf_len = 200;
buf = new char [buf_len];
FILE *fp_src, *fp_dest;
char *filename = printer->CreateActionFile();
sprintf(buf, "%s.%ld", filename, (long)getpid());
if (fp_dest = fopen(buf, "w"))
{
if (fp_src = fopen(filename, "r"))
{
while (fgets(buf, buf_len, fp_src))
{
if (strstr(buf, "LABEL"))
fprintf(fp_dest, " LABEL %s\n",
iconName);
else if (strstr(buf, "ICON"))
fprintf(fp_dest, " ICON %s\n",
iconFile);
else
fprintf(fp_dest, "%s", buf);
}
fclose(fp_src);
}
}
fclose(fp_dest);
sprintf(buf, "%s.%ld", filename, (long)getpid());
rename(buf, filename);
DtActionInvoke(((AnyUI *)mainw->Parent())->BaseWidget(), "ReloadActions",
NULL, 0, NULL, NULL, NULL, True, NULL, NULL);
delete [] buf;
mainw->WorkingCursor(false);
mainw->status_line->Name(save_msg);
}
void DtPrtProps::CloseCB()
{
Reset();
Visible(false);
}
void DtPrtProps::OkCB(void *data)
{
DtPrtProps *obj = (DtPrtProps *) data;
obj->Apply();
obj->Visible(false);
}
void DtPrtProps::ApplyCB(void *data)
{
DtPrtProps *obj = (DtPrtProps *) data;
obj->Apply();
}
void DtPrtProps::CancelCB(void *data)
{
DtPrtProps *obj = (DtPrtProps *) data;
obj->Reset();
obj->Visible(false);
}
void DtPrtProps::ResetCB(void *data)
{
DtPrtProps *obj = (DtPrtProps *) data;
obj->Reset();
}
void DtPrtProps::HelpCB(void *data)
{
DtPrtProps *obj = (DtPrtProps *) data;
obj->HandleHelpRequest();
}
boolean DtPrtProps::HandleHelpRequest()
{
mainw->DisplayHelp((char *)PROPS_PRINTER_ID);
return true;
}
void DtPrtProps::SetActionIcons(const char *icon)
{
delete _iconFile;
_iconFile = STRDUP(icon);
largeIcon->IconFile((char*)icon);
mediumIcon->IconFile((char*)icon);
smallIcon->IconFile((char*)icon);
}
void DtPrtProps::CallerCB(BaseUI *caller, char *iconFile)
{
DtPrtProps *obj = (DtPrtProps *)caller;
delete obj->_iconFile;
obj->_iconFile = STRDUP(iconFile);
obj->smallIcon->IconFile(iconFile);
obj->mediumIcon->IconFile(iconFile);
obj->largeIcon->IconFile(iconFile);
}
void DtPrtProps::FindSetCB(void *data)
{
DtPrtProps *obj = (DtPrtProps *)data;
if (!obj->mainw->findSetD)
{
char *name = new char [strlen(obj->mainw->Name()) +
strlen(MESSAGE(FindSetTitleL))];
sprintf(name, MESSAGE(FindSetTitleL), obj->mainw->Name());
obj->mainw->findSetD = new DtFindSet(obj->mainw, name,
&DtPrtProps::CallerCB);
delete [] name;
}
obj->mainw->findSetD->Caller(obj);
obj->mainw->findSetD->Visible(true);
}

View File

@@ -0,0 +1,83 @@
/* $XConsortium: DtPrtProps.h /main/3 1995/11/06 09:36:44 rswiston $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifndef DTPRTPROPS_H
#define DTPRTPROPS_H
#include "Dialog.h"
#include "Prompt.h"
class Button;
class DtMainW;
class Group;
class LabelObj;
class IconObj;
class DtPrinterIcon;
class DtFindSet;
class DtPrtProps : public Dialog {
friend class DtFindIcon;
friend void OkCB(void *data);
friend void ApplyCB(void *data);
friend void CancelCB(void *data);
friend void ResetCB(void *data);
friend void HelpCB(void *data);
friend void FindSetCB(void *data);
friend void CallerCB(BaseUI *, char *);
static void OkCB(void *data);
static void ApplyCB(void *data);
static void CancelCB(void *data);
static void ResetCB(void *data);
static void HelpCB(void *data);
static void FindSetCB(void *data);
static void CallerCB(BaseUI *, char *);
private:
DtMainW *mainw;
// dialog buttons
Button *ok;
Button *apply;
Button *cancel;
Button *reset;
Button *help;
Group *icon_group;
Prompt *icon_prompt;
Prompt *description;
DtFindSet *findSetD;
boolean _has_been_posted;
char *_iconFile;
DtPrinterIcon *printer;
IconObj *smallIcon;
IconObj *mediumIcon;
IconObj *largeIcon;
Button *find_set;
void SetActionIcons(const char *icon);
void CloseCB();
boolean SetVisiblity(boolean);
boolean HandleHelpRequest();
public:
DtPrtProps(DtMainW *, char *name, DtPrinterIcon *printer);
~DtPrtProps();
DtPrinterIcon *Printer() { return printer; }
void Printer(DtPrinterIcon *printer);
const char *IconFileName() { return _iconFile; }
char *IconLabel() { return icon_prompt->Value(); }
void IconLabel(char *value) { icon_prompt->Value(value); }
void Apply();
void Reset();
};
#endif // DTPRTPROPS_H

View File

@@ -0,0 +1,190 @@
/* $XConsortium: DtSetModList.C /main/2 1995/07/17 14:04:17 drk $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#include "DtSetModList.h"
#include "DtMainW.h"
#include "DtWorkArea.h"
#include "Button.h"
#include "IconObj.h"
#include "LabelObj.h"
#include "Container.h"
#include "dtprintinfomsg.h"
DtSetModList::DtSetModList(AnyUI *parent,
char *name,
BaseUI *workarea,
ButtonCallback filterCB)
: Dialog(parent, name)
{
mainw = (DtMainW *) parent;
_has_been_posted = false;
_info = new LabelObj(this, MESSAGE(SelectPrintersToBeShowL));
_container = new Container(this, "FilterList", SCROLLED_VERTICAL_ROW_COLUMN,
MULTIPLE_SELECT);
_container->IconView(SMALL_ICON);
_filterCB = filterCB;
_workarea = (Container *) workarea;
Container *form = new Container(this, "Form", FORM);
_info->AttachRight();
_info->AttachLeft();
_info->AttachTop();
form->AttachBottom();
form->AttachRight();
form->AttachLeft();
_container->AttachBottom(form, 5);
_container->AttachRight();
_container->AttachLeft();
_container->AttachTop(_info);
select_all = new Button(form, MESSAGE(SelectAllL), PUSH_BUTTON, SelectAllCB,
_container);
unselect_all = new Button(form, MESSAGE(DeselectAllL), PUSH_BUTTON,
UnSelectAllCB, _container);
int i;
IconObj **objs = (IconObj **) workarea->Children();
for (i = 0; i < workarea->NumChildren(); i++)
{
if (objs[i]->UIClass() == ICON)
{
IconObj *icon = new IconObj(_container, (char *)objs[i]->Name(),
objs[i]->IconFile());
icon->ApplicationData = objs[i];
}
}
ok = new Button(this, MESSAGE(OKL), PUSH_BUTTON, OkCB, this);
apply = new Button(this, MESSAGE(ApplyL), PUSH_BUTTON, ApplyCB, this);
cancel = new Button(this, MESSAGE(CancelL), PUSH_BUTTON, CancelCB, this);
help = new Button(this, MESSAGE(HelpL), PUSH_BUTTON, HelpCB, this);
DefaultButton(ok);
CancelButton(cancel);
Reset();
}
DtSetModList::~DtSetModList()
{
// Empty
}
boolean DtSetModList::SetVisiblity(boolean flag)
{
if (_has_been_posted == false)
{
int height;
if (_container->NumChildren())
{
BaseUI **kids = _container->Children();
height = (kids[0]->Height() + 4) * _container->NumChildren();
if (height > 300)
height = 300;
}
else
height = 200;
int width = StringWidth(Name()) + 30;
if (Width() < width)
{
width -= 10;
_container->WidthHeight(width, height);
}
else
_container->Height(height);
_has_been_posted = true;
int offset = (width - (select_all->Width() + unselect_all->Width())) / 3;
select_all->AttachLeft(offset);
unselect_all->AttachRight(offset);
unselect_all->AttachLeft(NULL, 0);
}
Reset();
Dialog::SetVisiblity(flag);
return true;
}
void DtSetModList::Reset()
{
int i;
IconObj **children = (IconObj **) _container->Children();
mainw->container->BeginUpdate();
for (i = 0; i < _container->NumChildren(); i++)
{
IconObj *icon = (IconObj *)children[i]->ApplicationData;
children[i]->Selected(icon->Visible());
if (strcmp(icon->Name(), children[i]->Name()))
children[i]->Name((char *)icon->Name());
if (strcmp(icon->IconFile(), children[i]->IconFile()))
children[i]->IconFile(icon->IconFile());
}
mainw->container->EndUpdate();
}
void DtSetModList::Apply()
{
if (_filterCB)
(*_filterCB)((void *)_container);
}
void DtSetModList::OkCB(void *data)
{
DtSetModList *obj = (DtSetModList *) data;
obj->Apply();
obj->Visible(false);
}
void DtSetModList::Cancel()
{
Reset();
Visible(false);
}
void DtSetModList::CloseCB()
{
Cancel();
}
void DtSetModList::CancelCB(void *data)
{
DtSetModList *obj = (DtSetModList *) data;
obj->Cancel();
}
void DtSetModList::ApplyCB(void *data)
{
DtSetModList *obj = (DtSetModList *) data;
obj->Apply();
}
void DtSetModList::SelectAllCB(void *data)
{
Container *obj = (Container *) data;
obj->SelectAll();
}
void DtSetModList::UnSelectAllCB(void *data)
{
Container *obj = (Container *) data;
obj->SelectAll(false);
}
void DtSetModList::HelpCB(void *data)
{
DtSetModList *obj = (DtSetModList *) data;
obj->HandleHelpRequest();
}
boolean DtSetModList::HandleHelpRequest()
{
mainw->DisplayHelp("ShowPrintersDE");
return true;
}

View File

@@ -0,0 +1,68 @@
/* $XConsortium: DtSetModList.h /main/3 1995/11/06 09:36:56 rswiston $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifndef DTSETMODLIST_H
#define DTSETMODLIST_H
#include "Dialog.h"
class Button;
class Container;
class LabelObj;
class DtMainW;
class DtSetModList : public Dialog {
friend void OkCB(void *);
friend void ApplyCB(void *);
friend void CancelCB(void *);
friend void HelpCB(void *);
friend void SelectAllCB(void *);
friend void UnSelectAllCB(void *);
private:
boolean _has_been_posted;
Container *_container;
DtMainW *mainw;
Container *_workarea;
LabelObj *_info;
Button *select_all;
Button *unselect_all;
// dialog buttons
Button *ok;
Button *apply;
Button *cancel;
Button *help;
static void OkCB(void *);
static void ApplyCB(void *);
static void CancelCB(void *);
static void HelpCB(void *);
static void SelectAllCB(void *);
static void UnSelectAllCB(void *);
boolean SetVisiblity(boolean flag);
ButtonCallback _filterCB;
void CloseCB();
void Apply();
void Cancel();
boolean HandleHelpRequest();
public:
DtSetModList(AnyUI *parent, char *name, BaseUI *container,
ButtonCallback filterCB);
virtual ~DtSetModList();
void Reset();
};
#endif /* DTSETMODLIST_H */

View File

@@ -0,0 +1,312 @@
/* $XConsortium: DtSetPref.C /main/2 1995/07/17 14:04:26 drk $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#include "DtSetPref.h"
#include "DtMainW.h"
#include "DtFindD.h"
#include "IconObj.h"
#include "Group.h"
#include "LabelObj.h"
#include "Container.h"
#include "Application.h"
#include "dtprintinfomsg.h"
DtSetPref::DtSetPref(AnyUI *parent,
char *name,
AnyUI *container,
PreferenceCallback callback,
void *callback_data)
: Dialog(parent, name, MODELESS, false)
{
mainw = (DtMainW *) parent;
_has_been_posted = false;
_container = container;
_callback = callback;
_callback_data = callback_data;
// initialize previous values
_previous_style = container->IconView();
_previous_status_flag = true;
_previous_status_line = true;
_previous_show_only_mine = false;
_previous_show_details_label = true;
_previous_update_interval = 30;
view_group = new Group(this, MESSAGE(RepresentationL));
by_icon = new Button(view_group, MESSAGE(LargeIconL), TOGGLE_BUTTON,
RepCB, this);
by_smallIcon = new Button(view_group, MESSAGE(SmallIconL), TOGGLE_BUTTON,
RepCB, this);
by_name = new Button(view_group, MESSAGE(NameOnlyL), TOGGLE_BUTTON,
RepCB, this);
by_properties = new Button(view_group, MESSAGE(DetailsL), TOGGLE_BUTTON,
RepCB, this);
Container *form = new Container(view_group, "form", FORM);
show_labels = new Button(form, MESSAGE(ShowLabelsL), TOGGLE_BUTTON);
show_labels->Selected(true);
show_labels->Active(false);
show_labels->AttachTop();
show_labels->AttachBottom();
show_labels->AttachRight();
show_labels->AttachLeft(20);
show_jobs = new Group(this, MESSAGE(JobsToShowL));
only_mine = new Button(show_jobs, MESSAGE(OnlyMineL), TOGGLE_BUTTON);
everyones = new Button(show_jobs, MESSAGE(EveryoneL), TOGGLE_BUTTON);
everyones->Selected(true);
update_group = new Group(this, MESSAGE(UpdateIntervalL), FORM_BOX);
update_interval = new ScaleObj(update_group, MESSAGE(IntervalL),
30, 0, 5, 300, 5, HORIZONTAL_SCALE, true);
update_interval->AttachAll();
update_group->AttachRight();
update_group->AttachLeft();
update_group->AttachBottom();
status = new Group(this, MESSAGE(StatusL), CHECK_BOX);
status_flag = new Button(status, MESSAGE(ProblemFlagL), TOGGLE_BUTTON);
status_flag->Selected(true);
status_line = new Button(status, MESSAGE(InformationLineL), TOGGLE_BUTTON);
status_line->Selected(true);
status->AttachRight();
status->AttachLeft(view_group, 5);
status->AttachBottom(update_group, 5);
view_group->AttachBottom(update_group, 5);
show_jobs->AttachBottom(status, 5);
view_group->AttachLeft();
view_group->AttachTop();
show_jobs->AttachLeft(view_group, 5);
show_jobs->AttachRight();
show_jobs->AttachTop();
ok = new Button(this, MESSAGE(OKL), PUSH_BUTTON, OkCB, this);
apply = new Button(this, MESSAGE(ApplyL), PUSH_BUTTON, ApplyCB, this);
cancel = new Button(this, MESSAGE(CancelL), PUSH_BUTTON, CancelCB, this);
help = new Button(this, MESSAGE(HelpL), PUSH_BUTTON, HelpCB, this);
DefaultButton(ok);
Reset();
}
DtSetPref::~DtSetPref()
{
// Empty
}
boolean DtSetPref::SetVisiblity(boolean flag)
{
Dialog::SetVisiblity(flag);
if (_has_been_posted == false)
{
_has_been_posted = true;
CancelButton(cancel);
}
return true;
}
void DtSetPref::ShowOnlyMyJobs(boolean value)
{
only_mine->Selected(value);
everyones->Selected(value ? false : true);
}
void DtSetPref::Representation(IconStyle value)
{
by_name->Selected(false);
by_icon->Selected(false);
by_smallIcon->Selected(false);
by_properties->Selected(false);
switch (value)
{
case NAME_ONLY: by_name->Selected(true); break;
case LARGE_ICON: by_icon->Selected(true); break;
case SMALL_ICON: by_smallIcon->Selected(true); break;
case DETAILS: by_properties->Selected(true); break;
}
show_labels->Active(by_properties->Selected());
}
void DtSetPref::Reset()
{
Representation(_previous_style);
status_flag->Selected(_previous_status_flag);
status_line->Selected(_previous_status_line);
(void)update_interval->Value();
update_interval->Value(_previous_update_interval);
ShowOnlyMyJobs(_previous_show_only_mine);
show_labels->Selected(_previous_show_details_label);
}
static void TurnOffHourGlass(BaseUI *obj, void *data)
{
((DtMainW *)obj)->WorkingCursor(false);
((Container *)data)->EndUpdate();
}
void DtSetPref::Apply()
{
IconStyle style;
boolean add_timeout = false;
if (by_name->Selected())
style = NAME_ONLY;
else if (by_icon->Selected())
style = LARGE_ICON;
else if (by_smallIcon->Selected())
style = SMALL_ICON;
else if (by_properties->Selected())
style = DETAILS;
if (_previous_style != style)
{
if (mainw->PrinterAppMode() == PRINT_MANAGER)
{
mainw->WorkingCursor(true);
_container->BeginUpdate();
add_timeout = true;
}
_container->IconView(style);
if (_callback)
{
if (_previous_style == DETAILS)
(*_callback)(_callback_data, DETAILS_OFF, NULL);
else if (style == DETAILS)
(*_callback)(_callback_data, DETAILS_ON, NULL);
}
_previous_style = style;
if (_callback)
{
if (_previous_show_details_label)
(*_callback)(_callback_data, SHOW_DETAILS_LABEL_ON, NULL);
else
(*_callback)(_callback_data, SHOW_DETAILS_LABEL_OFF, NULL);
}
}
if (_previous_status_flag != status_flag->Selected())
{
_previous_status_flag = status_flag->Selected();
if (_callback)
{
if (_previous_status_flag)
(*_callback)(_callback_data, STATUS_FLAG_ON, NULL);
else
(*_callback)(_callback_data, STATUS_FLAG_OFF, NULL);
}
}
if (_previous_status_line != status_line->Selected())
{
_previous_status_line = status_line->Selected();
if (_callback)
{
if (_previous_status_line)
(*_callback)(_callback_data, STATUS_LINE_ON, NULL);
else
(*_callback)(_callback_data, STATUS_LINE_OFF, NULL);
}
}
if (_previous_show_only_mine != only_mine->Selected())
{
if (mainw->PrinterAppMode() == PRINT_MANAGER)
{
mainw->WorkingCursor(true);
_container->BeginUpdate();
add_timeout = true;
}
_previous_show_only_mine = only_mine->Selected();
if (_callback)
{
if (_previous_show_only_mine)
(*_callback)(_callback_data, SHOW_ONLY_MINE_ON, NULL);
else
(*_callback)(_callback_data, SHOW_ONLY_MINE_OFF, NULL);
if (_previous_show_details_label)
(*_callback)(_callback_data, SHOW_DETAILS_LABEL_ON, NULL);
else
(*_callback)(_callback_data, SHOW_DETAILS_LABEL_OFF, NULL);
}
}
if (_previous_show_details_label != show_labels->Selected())
{
_previous_show_details_label = show_labels->Selected();
if (_callback)
{
if (_previous_show_details_label)
(*_callback)(_callback_data, SHOW_DETAILS_LABEL_ON, NULL);
else
(*_callback)(_callback_data, SHOW_DETAILS_LABEL_OFF, NULL);
}
}
if (update_interval->Value() != _previous_update_interval)
{
_previous_update_interval = update_interval->Value();
if (_callback)
(*_callback)(_callback_data, UPDATE_INTERVAL_CHANGED,
(char *) _previous_update_interval);
}
if (mainw->findD)
mainw->findD->UpdateMatchAnyUser();
if (add_timeout)
mainw->AddTimeOut(TurnOffHourGlass, _container, 1500);
}
void DtSetPref::OkCB(void *data)
{
DtSetPref *obj = (DtSetPref *) data;
obj->Apply();
obj->Visible(false);
}
void DtSetPref::Cancel()
{
Reset();
Visible(false);
}
void DtSetPref::CancelCB(void *data)
{
DtSetPref *obj = (DtSetPref *) data;
obj->Cancel();
}
void DtSetPref::CloseCB()
{
Cancel();
}
void DtSetPref::ApplyCB(void *data)
{
DtSetPref *obj = (DtSetPref *) data;
obj->Apply();
}
void DtSetPref::HelpCB(void *data)
{
DtSetPref *obj = (DtSetPref *) data;
obj->HandleHelpRequest();
}
void DtSetPref::RepCB(void *data)
{
DtSetPref *obj = (DtSetPref *) data;
obj->show_labels->Active(obj->by_properties->Selected());
}
boolean DtSetPref::HandleHelpRequest()
{
mainw->DisplayHelp("SetOptionsDE");
return true;
}

View File

@@ -0,0 +1,118 @@
/* $XConsortium: DtSetPref.h /main/3 1995/11/06 09:37:08 rswiston $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifndef DTSETPREF_H
#define DTSETPREF_H
#include "Dialog.h"
#include "Button.h"
#include "ScaleObj.h"
class Group;
class DtMainW;
typedef enum
{
DETAILS_ON,
DETAILS_OFF,
STATUS_LINE_ON,
STATUS_LINE_OFF,
STATUS_FLAG_ON,
STATUS_FLAG_OFF,
SHOW_ONLY_MINE_ON,
SHOW_ONLY_MINE_OFF,
SHOW_DETAILS_LABEL_ON,
SHOW_DETAILS_LABEL_OFF,
UPDATE_INTERVAL_CHANGED
} PreferenceRequest;
typedef void (*PreferenceCallback) (void *callback_data, PreferenceRequest,
char *value);
class DtSetPref : public Dialog {
friend void OkCB(void *);
friend void ApplyCB(void *);
friend void CancelCB(void *);
friend void HelpCB(void *);
friend void RepCB(void *);
private:
boolean _has_been_posted;
IconStyle _previous_style;
boolean _previous_status_flag;
boolean _previous_status_line;
boolean _previous_show_only_mine;
boolean _previous_show_details_label;
int _previous_update_interval;
AnyUI *_container;
PreferenceCallback _callback;
void *_callback_data;
DtMainW *mainw;
Group *show_jobs;
Button *only_mine;
Button *everyones;
Group *status;
Button *status_line;
Button *status_flag;
Group *view_group;
Button *by_name;
Button *by_icon;
Button *by_smallIcon;
Button *by_properties;
Button *show_labels;
Group *update_group;
ScaleObj *update_interval;
// dialog buttons
Button *ok;
Button *apply;
Button *cancel;
Button *help;
static void OkCB(void *);
static void ApplyCB(void *);
static void CancelCB(void *);
static void HelpCB(void *);
static void RepCB(void *);
void CloseCB();
boolean SetVisiblity(boolean flag);
void Cancel();
void Reset();
boolean HandleHelpRequest();
public:
DtSetPref(AnyUI *parent, char *name, AnyUI *container,
PreferenceCallback callback, void *callback_data);
virtual ~DtSetPref();
void Apply();
boolean ShowStatusFlags() { return _previous_status_flag; }
boolean ShowStatusLine() { return _previous_status_line; }
boolean ShowOnlyMyJobs() { return _previous_show_only_mine; }
boolean ShowDetailsLabel() { return _previous_show_details_label; }
IconStyle Represetation() { return _previous_style; }
int UpdateInterval() { return _previous_update_interval; }
void Representation(IconStyle);
void ShowOnlyMyJobs(boolean);
void ShowStatusFlags(boolean value) { status_flag->Selected(value); }
void ShowStatusLine(boolean value) { status_line->Selected(value); }
void ShowDetailsLabel(boolean value) { show_labels->Selected(value); }
void UpdateInterval(int value) { update_interval->Value(value); }
};
#endif /* DTSETPREF_H */

View File

@@ -0,0 +1,46 @@
/* $XConsortium: DtWorkArea.C /main/2 1995/07/17 14:04:34 drk $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#include "DtWorkArea.h"
#include "DtMainW.h"
#include "DtActions.h"
DtWorkArea::DtWorkArea(char *category,
AnyUI *parent,
char *name,
ContainerType container_type,
SelectionType select_type)
: Container(category, parent, name, container_type, select_type)
{
_mainW = (DtMainW *) parent->Parent();
}
void DtWorkArea::NotifySelected(BaseUI *obj)
{
Container::NotifySelected(obj);
if (_mainW->UIClass() != MAIN_WINDOW)
return;
BaseUI **selection;
int n_items;
Selection(&n_items, &selection);
if (n_items)
_mainW->actionsMenu->UpdateActions(n_items, selection[0]);
else
_mainW->actionsMenu->UpdateActions(n_items, NULL);
delete []selection;
}
void DtWorkArea::NotifyOpen(BaseUI *obj)
{
if (_mainW->UIClass() != MAIN_WINDOW)
return;
_mainW->OpenClose(obj);
}

View File

@@ -0,0 +1,33 @@
/* $XConsortium: DtWorkArea.h /main/3 1995/11/06 09:37:19 rswiston $ */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
* (c) Copyright 1993, 1994 International Business Machines Corp. *
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#ifndef DTWORKAREA_H
#define DTWORKAREA_H
#include "Container.h"
class DtMainW;
class DtWorkArea : public Container
{
private:
DtMainW * _mainW;
void NotifySelected(BaseUI *obj);
void NotifyOpen(BaseUI *obj);
public:
DtWorkArea(char *category, AnyUI *parent, char *name,
ContainerType = SCROLLED_WORK_AREA,
SelectionType = SINGLE_SELECT);
};
#endif // DTWORKAREA_H

View File

@@ -0,0 +1,33 @@
XCOMM $XConsortium: Imakefile /main/6 1996/04/21 19:50:41 drk $
#define DoNormalLib YES
#define DoSharedLib NO
#define DoDebugLib NO
#define DoProfileLib NO
#define LibName DtPrintinfo
#define LibHeaders NO
#define LibInstall NO
#define CplusplusSource YES
DEPEND_DEFINES = $(CXXDEPENDINCLUDES)
INCLUDES = -I. -I.. -I../libUI -I../libUI/MotifUI -I../objects -I../util -I../objects -I../objects/PrintObj
#ifdef RsArchitecture
DEFINES = -DHAS_EXCEPTIONS
#endif
SRCS = DtActions.C DtApp.C DtDetailsLabel.C \
DtFindD.C DtFindSet.C DtMainW.C \
DtPrinterIcon.C DtProps.C DtPrtJobIcon.C \
DtPrtProps.C DtSetModList.C DtSetPref.C \
DtWorkArea.C
OBJS = DtActions.o DtApp.o DtDetailsLabel.o \
DtFindD.o DtFindSet.o DtMainW.o \
DtPrinterIcon.o DtProps.o DtPrtJobIcon.o \
DtPrtProps.o DtSetModList.o DtSetPref.o \
DtWorkArea.o
#include <Library.tmpl>
DependTarget()