Back to index

tetex-bin  3.0
Defines | Functions | Variables
print-log.c File Reference
#include <string.h>
#include "xdvi-config.h"
#include "xdvi.h"
#include "xdvi-debug.h"
#include "print-dialog.h"
#include "print-log.h"
#include "util.h"
#include "x_util.h"
#include "xlwradio.h"
#include <X11/Xatom.h>
#include <X11/StringDefs.h>
#include <X11/Shell.h>
#include <X11/Xaw/Paned.h>
#include <X11/Xaw/Box.h>
#include <X11/Xaw/Form.h>
#include <X11/Xaw/Label.h>
#include <X11/Xaw/Command.h>
#include <X11/Xaw/Toggle.h>
#include <X11/Xaw/AsciiText.h>

Go to the source code of this file.

Defines

#define XawFmt8Bit   FMT8BIT

Functions

static void printlog_act_close (Widget, XEvent *, String *, Cardinal *)
static void printlog_act_keep (Widget, XEvent *, String *, Cardinal *)
static void printlog_act_unkeep (Widget, XEvent *, String *, Cardinal *)
static void printlog_act_cancel (Widget, XEvent *, String *, Cardinal *)
static void printlog_act_destroy (Widget, XEvent *, String *, Cardinal *)
Boolean printlog_raise_active (void)
void printlog_popup (void)
void printlog_reset (void)
void printlog_create (const char *title, const char *close_label, void(*close_callback)(Widget w, XtPointer client_data, XtPointer call_data), void(*cancel_callback)(Widget w, XtPointer client_data, XtPointer call_data), void(*destroy_callback)(Widget w, XtPointer client_data, XtPointer call_data), void(*unkeep_callback)(Widget w, XtPointer client_data, XtPointer call_data))
void printlog_append (const char *str, size_t len)
void printlog_append_str (const char *str)
void printlog_enable_closebutton (void)
static void printlog_internal_close (void)
void printlog_popdown (Boolean force)

Variables

static Boolean printlog_active = False
static Widget printlog_shell = NULL
static void(* g_close_callback )(Widget w, XtPointer client_data, XtPointer call_data)
static void(* g_cancel_callback )(Widget w, XtPointer client_data, XtPointer call_data)
static void(* g_destroy_callback )(Widget w, XtPointer client_data, XtPointer call_data)
static Atom WM_DELETE_WINDOW
static XtActionsRec printlog_actions []
static char * text_translations = "^<Key>q:printlogIntUnkeep()"
static Widget printlog_text
static Widget printlog_close
static Widget printlog_unkeep
static Widget printlog_cancel
static XawTextPosition printlog_length

Define Documentation

#define XawFmt8Bit   FMT8BIT

Definition at line 65 of file print-log.c.


Function Documentation

static void printlog_act_cancel ( Widget  w,
XEvent *  event,
String params,
Cardinal *  num_params 
) [static]

Definition at line 531 of file print-log.c.

{
    UNUSED(w);
    UNUSED(event);
    UNUSED(params);
    UNUSED(num_params);

    ASSERT(g_cancel_callback != NULL, "Callback not initialized");
    (g_cancel_callback)(NULL, NULL, NULL);
}
static void printlog_act_close ( Widget  w,
XEvent *  event,
String params,
Cardinal *  num_params 
) [static]

Definition at line 488 of file print-log.c.

{
    UNUSED(w);
    UNUSED(event);
    UNUSED(params);
    UNUSED(num_params);

    ASSERT(g_close_callback != NULL, "Callback not initialized");
    (g_close_callback)(NULL, NULL, NULL);
}
static void printlog_act_destroy ( Widget  w,
XEvent *  event,
String params,
Cardinal *  num_params 
) [static]

Definition at line 543 of file print-log.c.

{
    UNUSED(w);
    UNUSED(event);
    UNUSED(params);
    UNUSED(num_params);

    ASSERT((g_destroy_callback) != NULL, "Callback not initialized");
    (g_destroy_callback)(NULL, NULL, NULL);
}
static void printlog_act_keep ( Widget  w,
XEvent *  event,
String params,
Cardinal *  num_params 
) [static]

Definition at line 500 of file print-log.c.

{
    UNUSED(w);
    UNUSED(event);
    UNUSED(params);
    UNUSED(num_params);

#ifdef MOTIF
    XmToggleButtonGadgetSetState(printlog_unkeep, False, False);
#else
    XtVaSetValues(printlog_unkeep, XtNstate, False, NULL);
#endif
}
static void printlog_act_unkeep ( Widget  w,
XEvent *  event,
String params,
Cardinal *  num_params 
) [static]

Definition at line 517 of file print-log.c.

{
    UNUSED(w);
    UNUSED(event);
    UNUSED(params);
    UNUSED(num_params);
#ifdef MOTIF
    XmToggleButtonGadgetSetState(printlog_unkeep, True, False);
#else
    XtVaSetValues(printlog_unkeep, XtNstate, True, NULL);
#endif
}
void printlog_append ( const char *  str,
size_t  len 
)

Definition at line 407 of file print-log.c.

{
#ifndef MOTIF
    
    static XawTextBlock block = {0, 0, NULL, 0};

    block.ptr = (char *) str;
    block.length = len;
    block.format = XawFmt8Bit;
    while (XawTextReplace(printlog_text, printlog_length, printlog_length, &block)
          != XawEditDone) {
       int length;

       XtVaGetValues(printlog_text, XtNlength, &length, NULL);
       printlog_length = length;
    }
    printlog_length += len;
    XawTextSetInsertionPoint(printlog_text, printlog_length);

#else /* MOTIF */
    
    XmTextInsert(printlog_text, printlog_length, (char *) str);
    printlog_length += len;
    XtVaSetValues(printlog_text, XmNcursorPosition, printlog_length, NULL);
    XmTextShowPosition(printlog_text, printlog_length);
    
#endif /* MOTIF */
}

Here is the caller graph for this function:

void printlog_append_str ( const char *  str)

Definition at line 437 of file print-log.c.

{
    printlog_append(str, strlen(str));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void printlog_create ( const char *  title,
const char *  close_label,
void(*)(Widget w, XtPointer client_data, XtPointer call_data)  close_callback,
void(*)(Widget w, XtPointer client_data, XtPointer call_data)  cancel_callback,
void(*)(Widget w, XtPointer client_data, XtPointer call_data)  destroy_callback,
void(*)(Widget w, XtPointer client_data, XtPointer call_data)  unkeep_callback 
)

Definition at line 158 of file print-log.c.

{
    /*
      FIXME BETA: The printlog presents too much detail and is confusing for users.
      Re-implement it using an `printing page n of m' message,
      i.e. according to the spec on:
      http://xdvi.sourceforge.net/gui.html#file-print
      Possible save the detailed log to a different window that can be viewed
      via `File -> logs', as described on:
      http://xdvi.sourceforge.net/gui.html#file-logs
     */
    XtAddActions(printlog_actions, XtNumber(printlog_actions));
    g_destroy_callback = destroy_callback;
    
#ifndef MOTIF
    /* Create popup window */
    if (printlog_shell == NULL) {
       Widget form, box, paned;
/*     int ddist; */
/*     Dimension w0, w1, w2, w3, b; */
       
       XtTranslations wm_translations = XtParseTranslationTable("<Message>WM_PROTOCOLS: WM_destroy()");
       printlog_shell = XtVaCreatePopupShell("printlog",
                                         transientShellWidgetClass, globals.widgets.top_level,
                                         XtNtitle, title,
                                         XtNtransientFor, globals.widgets.top_level,
                                         XtNmappedWhenManaged, False,
                                         XtNtranslations, wm_translations,
                                         XtNtransientFor, globals.widgets.top_level,
                                         NULL);

       WM_DELETE_WINDOW = XInternAtom(XtDisplay(printlog_shell), "WM_DELETE_WINDOW", False);
       
       paned = XtVaCreateManagedWidget("paned", panedWidgetClass, printlog_shell, NULL);
       
       form = XtVaCreateManagedWidget("form", formWidgetClass,
                                 paned,
                                 XtNdefaultDistance, 6,
                                 NULL);
       printlog_text = XtVaCreateManagedWidget("text",
                                          asciiTextWidgetClass, form,
                                          XtNstring, "",
                                          XtNdataCompression, False,
                                          XtNeditType, XawtextAppend,
                                          XtNscrollHorizontal, XawtextScrollAlways,
                                          XtNscrollVertical, XawtextScrollAlways,
                                          XtNwidth, 600,
                                          XtNheight, 400,
                                          XtNleft, XawChainLeft,
                                          XtNright, XawChainRight,
                                          XtNtop, XawChainTop,
                                          XtNbottom, XawChainBottom,
                                          NULL);
       XtOverrideTranslations(printlog_text, XtParseTranslationTable(text_translations));

       printlog_unkeep = XtVaCreateManagedWidget("keep",
#ifdef XAW
                                            radioWidgetClass,
#else
                                            toggleWidgetClass,
#endif
                                            form,
                                            XtNlabel, close_label,
                                            XtNborderWidth, 0,
                                            XtNisRadio, False,
                                            XtNhighlightThickness, 1,
                                            XtNfromVert, printlog_text,
                                            XtNleft, XawChainLeft,
                                            XtNright, XawChainLeft,
                                            XtNtop, XawChainBottom,
                                            XtNbottom, XawChainBottom,
                                            NULL);
       XtVaSetValues(printlog_unkeep,
                    XtNstate, resource.dvips_hang > 0 && resource.dvips_fail_hang > 0,
                    NULL);
       XtAddCallback(printlog_unkeep, XtNcallback, unkeep_callback, NULL);
       
       /* box for the Close/Cancel button */
       box = XtVaCreateManagedWidget("box", formWidgetClass,
                                  paned,
                                  /* resizing by user isn't needed */
                                  XtNshowGrip, False,
                                  XtNdefaultDistance, 6, /* some padding */
                                  /* resizing the window shouldn't influence this box,
                                   * but  only the pane widget
                                   */
                                  XtNskipAdjust, True,
                                  XtNaccelerators, G_accels_cr,
                                  NULL);
       
       printlog_close = XtVaCreateManagedWidget("close",
                                           commandWidgetClass, box,
                                           XtNlabel, "Close",
                                           XtNsensitive, False,
                                           XtNleft, XawChainLeft,
                                           XtNright, XawChainLeft,
                                           XtNtop, XawChainBottom,
                                           XtNbottom, XawChainBottom,
                                           NULL);
       XtAddCallback(printlog_close, XtNcallback, close_callback, NULL);
       g_close_callback = close_callback;
       
       printlog_cancel = XtVaCreateManagedWidget("cancel",
                                            commandWidgetClass, box,
                                            XtNlabel, "Cancel",
                                            XtNfromHoriz, printlog_unkeep,
                                            XtNleft, XawChainRight,
                                            XtNright, XawChainRight,
                                            XtNtop, XawChainBottom,
                                            XtNbottom, XawChainBottom,
                                            NULL);
       XtAddCallback(printlog_cancel, XtNcallback, cancel_callback, NULL);
       g_cancel_callback = cancel_callback;
       XtManageChild(printlog_shell);
    }
    else {
       XtSetSensitive(printlog_close, False);
       XtSetSensitive(printlog_cancel, True);
    }
    
#else /* MOTIF */

    /* Create popup window */
    if (printlog_shell == NULL) {
       Widget form, pane, box;
       XmString str;
       Arg args[10];
       int n;
       
       printlog_shell = XtVaCreatePopupShell("printlog",
                                         xmDialogShellWidgetClass, globals.widgets.top_level,
                                         XmNdeleteResponse, XmDO_NOTHING, /* we'll take care of that ourselves */
                                         XmNtitle, title,
                                         XtNmappedWhenManaged, False,
                                         NULL);

       WM_DELETE_WINDOW = XmInternAtom(XtDisplay(printlog_shell), "WM_DELETE_WINDOW", False);
       XmAddWMProtocolCallback(printlog_shell, WM_DELETE_WINDOW, xm_printlog_act_destroy, NULL);

       pane = XtVaCreateWidget("printlog_pane", xmPanedWindowWidgetClass, printlog_shell,
                            /* make sashes invisible */
                            XmNsashWidth, 1,
                            XmNsashHeight, 1,
                            NULL);
       
       form = XtVaCreateWidget("form", xmFormWidgetClass, pane,
                            XmNhorizontalSpacing, DDIST,
                            XmNverticalSpacing, DDIST,
                            XmNautoUnmanage, False,
                            NULL);
       /* force vertical scrollbars. Under Motif 2.x (2.1.0 and 2.2.2 at least),
          XmNeditMode must be set early in order to have an effect. */
       n = 0;
       XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT);      n++;
       XtSetArg(args[n], XmNeditable, False);                  n++;
       XtSetArg(args[n], XmNrows, 24);                         n++;
       XtSetArg(args[n], XmNcolumns, 80);               n++;
       
       printlog_text = XmCreateScrolledText(form, "text", args, n);

       XtVaSetValues(XtParent(printlog_text),
                    XmNtopAttachment, XmATTACH_FORM,
                    XmNleftAttachment, XmATTACH_FORM,
                    XmNrightAttachment, XmATTACH_FORM,
                    NULL);

       XtManageChild(printlog_text);

       str = XmStringCreateLocalized((char *)close_label);
       printlog_unkeep = XtVaCreateManagedWidget("keep",
                                          xmToggleButtonGadgetClass, form,
                                          XmNlabelString, str,
                                          XmNnavigationType, XmTAB_GROUP,
                                          XmNtopAttachment, XmATTACH_WIDGET,
                                          XmNtopWidget, XtParent(printlog_text),
                                          XmNleftAttachment, XmATTACH_FORM,
                                          NULL);
       XmStringFree(str);
       XtAddCallback(printlog_unkeep, XmNvalueChangedCallback, unkeep_callback, NULL);
       XmToggleButtonGadgetSetState(printlog_unkeep, resource.dvips_hang > 0 && resource.dvips_fail_hang > 0, False);

       /* box for Close/Cancel button */
       box = XtVaCreateManagedWidget("box", xmFormWidgetClass,
                                  pane,
                                  NULL);
       
       str = XmStringCreateLocalized("Close");
       printlog_close = XtVaCreateManagedWidget("close",
                                           xmPushButtonWidgetClass, box,
                                           XmNlabelString, str,
                                           XmNshowAsDefault, True,
                                           XmNsensitive, False,
                                           XmNdefaultButtonShadowThickness, 1,
                                           XmNtopAttachment, XmATTACH_FORM,
                                           XmNbottomAttachment, XmATTACH_FORM,
                                           XmNleftAttachment, XmATTACH_FORM,
                                           /* to mimick appearance of native dialog buttons: */
                                           XmNmarginWidth, 6,
                                           XmNmarginHeight, 4,
                                           XmNtopOffset, 10,
                                           XmNbottomOffset, 10,
                                           XmNleftOffset, 10,
                                           NULL);
       XmStringFree(str);
       XtAddCallback(printlog_close, XmNactivateCallback, close_callback, NULL);
       g_close_callback = close_callback;

       str = XmStringCreateLocalized("Cancel");
       printlog_cancel = XtVaCreateManagedWidget("cancel",
                                            xmPushButtonWidgetClass, box,
                                            XmNlabelString, str,
                                            XmNdefaultButtonShadowThickness, 1,
                                            XmNtopAttachment, XmATTACH_FORM,
                                            XmNbottomAttachment, XmATTACH_FORM,
                                            XmNrightAttachment, XmATTACH_FORM,
                                            /* to mimick appearance of native dialog buttons: */
                                            XmNmarginWidth, 6,
                                            XmNmarginHeight, 4,
                                            XmNtopOffset, 10,
                                            XmNbottomOffset, 10,
                                            XmNrightOffset, 10,
                                            NULL);
       XmStringFree(str);
       XtAddCallback(printlog_cancel, XmNactivateCallback, cancel_callback, NULL);
       g_cancel_callback = cancel_callback;

       XtManageChild(box);
       XtManageChild(form);
       XtManageChild(pane);
/*     center_window(printlog_shell, globals.widgets.top_level); */
/*     XtMapWidget(printlog_shell); */
       /* this doesn't help */
       /* XtOverrideTranslations(form, XtParseTranslationTable(text_translations)); */
       /* XtOverrideTranslations(pane, XtParseTranslationTable(text_translations)); */
    }
    else {
       XtSetSensitive(printlog_close, False);
       XtSetSensitive(printlog_cancel, True);
    }
#endif
    adjust_width(printlog_close, printlog_cancel);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 444 of file print-log.c.

{
    XtSetSensitive(printlog_close, True);
    XtSetSensitive(printlog_cancel, False);
#if MOTIF
    XmProcessTraversal(printlog_close, XmTRAVERSE_CURRENT);
#endif
}

Here is the caller graph for this function:

static void printlog_internal_close ( void  ) [static]

Definition at line 454 of file print-log.c.

{
    XtUnmapWidget(printlog_shell);
    printlog_active = False;
#ifndef MOTIF
    XtVaSetValues(printlog_text, XtNstring, "", NULL);
#else
    XmTextSetString(printlog_text, "");
#endif
}

Here is the caller graph for this function:

Definition at line 466 of file print-log.c.

{
    if (force) { /* user clicked on `Close' */
       printlog_internal_close();
    }
    else { /* timer elapsed */
#ifndef MOTIF
       Boolean state;
       XtVaGetValues(printlog_unkeep, XtNstate, &state, NULL);
       if (state) {
           printlog_internal_close();
       }
#else
       if (XmToggleButtonGadgetGetState(printlog_unkeep)) {
           printlog_internal_close();
       }
#endif
    }    
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 134 of file print-log.c.

{
    printlog_length = 0;
    center_window(printlog_shell, globals.widgets.top_level);
    XtMapWidget(printlog_shell);
/*     XtPopup(printlog_shell, XtGrabNone); */
    printlog_active = True;
#ifndef MOTIF
    XSetWMProtocols(XtDisplay(printlog_shell), XtWindow(printlog_shell), &WM_DELETE_WINDOW, 1);
#else
    XmProcessTraversal(printlog_cancel, XmTRAVERSE_CURRENT);
    XtOverrideTranslations(printlog_text, XtParseTranslationTable(text_translations));
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 124 of file print-log.c.

{
    if (printlog_active) {
       XRaiseWindow(DISP, XtWindow(printlog_shell));
       return True;
    }
    return False;
}

Here is the caller graph for this function:

Definition at line 150 of file print-log.c.

{
    printlog_length = 0;
}

Here is the caller graph for this function:


Variable Documentation

void(* g_cancel_callback)(Widget w, XtPointer client_data, XtPointer call_data) [static]

Definition at line 75 of file print-log.c.

void(* g_close_callback)(Widget w, XtPointer client_data, XtPointer call_data) [static]

Definition at line 74 of file print-log.c.

void(* g_destroy_callback)(Widget w, XtPointer client_data, XtPointer call_data) [static]

Definition at line 76 of file print-log.c.

XtActionsRec printlog_actions[] [static]
Initial value:
 {
    {"printlogIntClose",    printlog_act_close},
    {"printlogIntKeep",            printlog_act_keep},
    {"printlogIntUnkeep",   printlog_act_unkeep},
    {"printlogIntCancel",   printlog_act_cancel},
    {"WM_destroy",          printlog_act_destroy },
}

Definition at line 97 of file print-log.c.

Definition at line 70 of file print-log.c.

Widget printlog_cancel [static]

Definition at line 114 of file print-log.c.

Widget printlog_close [static]

Definition at line 112 of file print-log.c.

XawTextPosition printlog_length [static]

Definition at line 120 of file print-log.c.

Widget printlog_shell = NULL [static]

Definition at line 71 of file print-log.c.

Widget printlog_text [static]

Definition at line 111 of file print-log.c.

Widget printlog_unkeep [static]

Definition at line 113 of file print-log.c.

char* text_translations = "^<Key>q:printlogIntUnkeep()" [static]

Definition at line 105 of file print-log.c.

Definition at line 95 of file print-log.c.