2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $TOG: DtActions.C /main/4 1998/08/03 16:30:18 mgreess $ */
25 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
26 * (c) Copyright 1993, 1994 International Business Machines Corp. *
27 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
28 * (c) Copyright 1993, 1994 Novell, Inc. *
33 #include "DtActions.h"
38 DtActions::DtActions(AnyUI *parent,
41 : Menu(parent, name, mnemonic)
46 class DtAction : public Button {
50 static void ActionCB(void *);
51 char *actionReferenceName;
52 ActionCallback actionCallback;
53 void *actionCallbackData;
57 DtAction(char *category, AnyUI *parent, char *name, char *mnemonic,
58 char *acceleratorText, char *accelerator, char *actionReferenceName,
59 ActionCallback callbackCB, void *callback_data);
62 DtAction::DtAction(char *category,
66 char *acceleratorText,
69 ActionCallback callbackCB,
71 : Button(category, parent, name, PUSH_BUTTON, NULL, NULL,
72 mnemonic, acceleratorText, accelerator)
74 actionReferenceName = strdup(actionName);
75 actionCallback = callbackCB;
76 actionCallbackData = callback_data;
82 free(actionReferenceName);
85 void DtAction::ActionCB(void *callback_data)
87 DtAction *action = (DtAction *) callback_data;
88 BaseUI *obj = ((DtActions *)action->Parent())->SelectedObject();
89 if (obj && action->actionCallback)
90 (*action->actionCallback)(action->actionCallbackData, obj,
91 action->actionReferenceName);
94 void DtActions::AddSep(char *objectClassName)
96 new Sep(objectClassName, this);
99 void DtActions::AddAction(char *name, char *category, char *actionReferenceName,
100 ActionCallback callback, void *callback_data,
101 char *mnemonic, char *acceleratorText,
104 new DtAction(category, this, name, mnemonic, acceleratorText, accelerator,
105 actionReferenceName, callback, callback_data);
108 void DtActions::UpdateActions(int n_items, BaseUI *obj)
114 for (i = 0; i < _numChildren; i++)
116 if (!_children[i]->Category() ||
117 !STRCMP(_children[i]->Category(), obj->Category()))
118 _children[i]->Visible(true);
120 _children[i]->Visible(false);
125 selected_object = obj;
128 boolean DtActions::HandleHelpRequest()
130 DtMainW *window = (DtMainW *)Parent()->Parent();
133 if (strcmp(selected_object->Category(), "Queue"))
134 window->DisplayHelp("SelectedPrintJobMenuDE");
136 window->DisplayHelp("SelectedPrinterMenuDE");
138 else if (window->PrinterAppMode() == PRINT_MANAGER)
139 window->DisplayHelp("SelectedMenuDE");
141 window->DisplayHelp("PJSelectedMenuDE");