summaryrefslogtreecommitdiffstats
path: root/kicker/menuext/tdeprint/print_mnu.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2011-11-06 15:56:34 -0600
committerTimothy Pearson <[email protected]>2011-11-06 15:56:34 -0600
commitb529f046c9a64ac5fcfa60747af940cf972b3ebc (patch)
tree83c28cf7fa8fed1960ebd3924b579e7ed8c95cc6 /kicker/menuext/tdeprint/print_mnu.cpp
parent6508fe4c40c60fd7a43bd3d9e19b762e10ea3f53 (diff)
downloadtdebase-b529f046c9a64ac5fcfa60747af940cf972b3ebc.tar.gz
tdebase-b529f046c9a64ac5fcfa60747af940cf972b3ebc.zip
Actually move the kde files that were renamed in the last commit
Diffstat (limited to 'kicker/menuext/tdeprint/print_mnu.cpp')
-rw-r--r--kicker/menuext/tdeprint/print_mnu.cpp139
1 files changed, 139 insertions, 0 deletions
diff --git a/kicker/menuext/tdeprint/print_mnu.cpp b/kicker/menuext/tdeprint/print_mnu.cpp
new file mode 100644
index 000000000..dee220d80
--- /dev/null
+++ b/kicker/menuext/tdeprint/print_mnu.cpp
@@ -0,0 +1,139 @@
+/*****************************************************************
+
+Copyright (c) 1996-2001 the kicker authors. See file AUTHORS.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+******************************************************************/
+
+#include "print_mnu.h"
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kglobal.h>
+#include <kapplication.h>
+#include <krun.h>
+#include <tdeprint/kmmanager.h>
+#include <tqregexp.h>
+
+K_EXPORT_KICKER_MENUEXT(tdeprint, PrintMenu)
+
+#define ADD_PRINTER_ID 0
+#define KDEPRINT_SETTINGS_ID 1
+#define CONFIG_SERVER_ID 2
+#define PRINT_MANAGER_ID 3
+#define PRINT_BROWSER_ID 4
+#define KPRINTER_ID 5
+#define PRINTER_LIST_ID 10
+
+PrintMenu::PrintMenu(TQWidget *parent, const char *name, const TQStringList & /*args*/)
+: KPanelMenu("", parent, name)
+{
+ static bool tdeprintIconsInitialized = false;
+ if ( !tdeprintIconsInitialized ) {
+ KGlobal::iconLoader()->addAppDir("tdeprint");
+ tdeprintIconsInitialized = true;
+ }
+}
+
+PrintMenu::~PrintMenu()
+{
+}
+
+void PrintMenu::initialize()
+{
+ if (initialized()) clear();
+ setInitialized(true);
+
+ int ID = PRINTER_LIST_ID;
+ // just to be sure the plugin is loaded -> icons are available
+ KMManager::self();
+
+ if ((KMManager::self()->printerOperationMask() & KMManager::PrinterCreation) && KMManager::self()->hasManagement())
+ insertItem(SmallIconSet("wizard"), i18n("Add Printer..."), ADD_PRINTER_ID);
+ insertItem(SmallIconSet("tdeprint_configmgr"), i18n("KDE Print Settings"), KDEPRINT_SETTINGS_ID);
+ if (KMManager::self()->serverOperationMask() & KMManager::ServerConfigure)
+ insertItem(SmallIconSet("tdeprint_configsrv"), i18n("Configure Server"), CONFIG_SERVER_ID);
+ insertSeparator();
+ insertItem(SmallIconSet("kcontrol"), i18n("Print Manager"), PRINT_MANAGER_ID);
+ insertItem(SmallIconSet("konqueror"), i18n("Print Browser (Konqueror)"), PRINT_BROWSER_ID);
+ insertSeparator();
+ insertItem(SmallIconSet("fileprint"), i18n("Print File..."), KPRINTER_ID);
+
+ // printer list
+ TQPtrList<KMPrinter> *l = KMManager::self()->printerList();
+ if (l && !l->isEmpty())
+ {
+ bool separatorInserted = false;
+ TQPtrListIterator<KMPrinter> it(*l);
+ for (; it.current(); ++it)
+ {
+ // no special, implicit or pure instances
+ if (it.current()->isSpecial() || it.current()->isVirtual())
+ continue;
+ if (!separatorInserted)
+ {
+ // we insert a separator only when we find the first
+ // printer
+ insertSeparator();
+ separatorInserted = true;
+ }
+ insertItem(SmallIconSet(it.current()->pixmap()),
+ it.current()->printerName(), ID++);
+ }
+ }
+}
+
+void PrintMenu::slotExec(int ID)
+{
+ switch (ID)
+ {
+ case ADD_PRINTER_ID:
+ kapp->tdeinitExec("kaddprinterwizard");
+ break;
+ case KDEPRINT_SETTINGS_ID:
+ kapp->tdeinitExec("kaddprinterwizard", TQStringList("--kdeconfig"));
+ break;
+ case CONFIG_SERVER_ID:
+ kapp->tdeinitExec("kaddprinterwizard", TQStringList("--serverconfig"));
+ break;
+ case PRINT_MANAGER_ID:
+ KRun::runCommand("kcmshell kde-printers.desktop");
+ break;
+ case PRINT_BROWSER_ID:
+ KRun::runCommand("kfmclient openProfile filemanagement print:/", "kfmclient", "konqueror");
+ break;
+ case KPRINTER_ID:
+ kapp->tdeinitExec("kprinter");
+ break;
+ default:
+ {
+ // start kjobviewer
+ TQStringList args;
+ args << "--show" << "-d" << text(ID).remove('&');
+ kapp->tdeinitExec("kjobviewer", args);
+ }
+ break;
+ }
+}
+
+void PrintMenu::reload()
+{
+ initialize();
+}
+
+#include "print_mnu.moc"