Use seperate main function for kdvi, to make it behave like a regular KDE program.

This is only temporarely until we get the plugin loader of kviewshell rewritten.

svn path=/trunk/kdegraphics/kdvi/; revision=364310
remotes/origin/kdvi-3.4
Wilfried Huss 22 years ago
parent 1c21aae62f
commit 6d9412d8fd
  1. 13
      Makefile.am
  2. 2
      kdvi
  3. 7
      kdvi.desktop
  4. 68
      kdvi_multipage.cpp
  5. 8
      kdvi_multipage.h
  6. 6
      kdvi_part.rc
  7. 138
      main.cpp

@ -3,9 +3,14 @@ INCLUDES= -I$(top_srcdir)/kviewshell $(all_includes) $(LIBFREETYPE_CFLAGS)
# claim, which subdirectories you want to install
SUBDIRS = . pix
bin_PROGRAMS = kdvi
# you can add here more. This one gets installed
kde_module_LTLIBRARIES= kdvipart.la
noinst_PROGRAMS = squeeze
noinst_LTLIBRARIES = ../kviewshell/libifaces.la
libifaces_la_SOURCES = ../kviewshell/kviewpart_iface.cpp
# just to make sure, automake makes them
METASOURCES = AUTO
@ -33,6 +38,10 @@ squeeze_SOURCES = squeeze.c
KDE_OPTIONS = nofinal
kdvi_SOURCES = main.cpp ../kviewshell/kviewshell.cpp
kdvi_LDFLAGS = $(all_libraries) $(KDE_RPATH)
kdvi_LDADD = ../kviewshell/libifaces.la -lkparts
## this option you can leave out. Just, if you use "make dist", you need it
noinst_HEADERS = dvi.h dviwin.h xdvi.h
@ -46,10 +55,8 @@ xdg_apps_DATA = kdvi.desktop
tip_DATA = tips
tipdir = $(kde_datadir)/kdvi
bin_SCRIPTS = kdvi
partdir = $(kde_datadir)/kdvi
part_DATA = kdvi_part.rc
part_DATA = ../kviewshell/kviewshell.rc kdvi_part.rc
psheader.c: psheader.txt squeeze
./squeeze $(srcdir)/psheader.txt $@

@ -1,2 +0,0 @@
#!/bin/sh
kviewshell dvi "$@"

@ -16,7 +16,6 @@ GenericName[el]=Προβολέας DVI
GenericName[eo]=DVI-rigardilo
GenericName[es]=Visor de documentos DVI
GenericName[et]=DVI failide vaataja
GenericName[fa]=نمایشگر دیویآی
GenericName[fi]=DVI-katsoja
GenericName[fr]=Afficheur DVI
GenericName[gl]=Visor de DVI
@ -29,7 +28,6 @@ GenericName[is]=DVI sjá
GenericName[it]=Visore DVI
GenericName[ja]=DVIビューア
GenericName[ko]=DVI 보기
GenericName[lo]=ຕວສະແດງຜນ DVI
GenericName[lt]=DVI Žiūriklis
GenericName[lv]=DVI Skatītājs
GenericName[mk]=Прикажувач на DVI
@ -37,7 +35,7 @@ GenericName[mt]=Werrej DVI
GenericName[nb]=DVI-fremviser
GenericName[nl]=DVI-weergaveprogramma
GenericName[nn]=DVI-lesar
GenericName[oc]=Visualisor DVI
GenericName[pa]=DVI ਦਰਸ਼ਕ
GenericName[pl]=Przeglądarka plików DVI
GenericName[pt]=Visualizador de DVIs
GenericName[pt_BR]=Visualizador de DVI
@ -48,7 +46,6 @@ GenericName[sk]=Prehliadač DVI súborov
GenericName[sl]=Pregledovalnik datotek DVI
GenericName[sr]=DVI приказивач
GenericName[sr@Latn]=DVI prikazivač
GenericName[ss]=Sibuki se DVI
GenericName[sv]=DVI-visare
GenericName[ta]=DVI கி
GenericName[tg]=Намоиши файли DVI
@ -71,7 +68,7 @@ Name[hi]=क-डआई
Name[xx]=xxKDVIxx
MimeType=application/x-dvi;application/x-gzdvi;application/x-bz2dvi;
InitialPreference=6
Exec=kviewshell dvi %f -caption "%c" %i %m
Exec=kdvi %f -caption "%c" %i %m
Icon=kdvi
Path=
Type=Application

@ -129,9 +129,6 @@ KDVIMultiPage::KDVIMultiPage(QWidget *parentWidget, const char *widgetName, QObj
exportTextAction = new KAction(i18n("Text..."), 0, this, SLOT(doExportText()), actionCollection(), "export_text");
KStdAction::tipOfDay(this, SLOT(showTip()), actionCollection(), "help_tipofday");
new KAction(i18n("About KDVI"), 0, this, SLOT(about()), actionCollection(), "about_kdvi");
new KAction(i18n("KDVI Handbook"), 0, this, SLOT(helpme()), actionCollection(), "help_dvi");
new KAction(i18n("Report Bug in KDVI..."), 0, this, SLOT(bugform()), actionCollection(), "bug_dvi");
setXMLFile("kdvi_part.rc");
@ -386,64 +383,6 @@ void KDVIMultiPage::addConfigDialogs(KConfigDialog* configDialog)
}
void KDVIMultiPage::about()
{
KAboutDialog *ab = new KAboutDialog(KAboutDialog::AbtAppStandard,
i18n("the KDVI plugin"),
KAboutDialog::Close, KAboutDialog::Close);
ab->setProduct("kdvi", "1.2", QString::null, QString::null);
ab->addTextPage (i18n("About"),
i18n("A previewer for Device Independent files (DVI files) produced "
"by the TeX typesetting system.<br>"
"Based on kdvi 0.4.3 and on xdvik, version 18f.<br><hr>"
"For latest information, visit "
"<a href=\"http://devel-home.kde.org/~kdvi\">KDVI's Homepage</a>."),
true);
ab->addTextPage (i18n("Authors"),
i18n("Stefan Kebekus<br>"
"<a href=\"http://www.mi.uni-koeln.de/~kebekus\">"
"http://www.mi.uni-koeln.de/~kebekus</a><br>"
"<a href=\"mailto:kebekus@kde.org\">kebekus@kde.org</a><br>"
"Current maintainer of kdvi. Major rewrite of version 0.4.3."
"Implementation of hyperlinks.<br>"
"<hr>"
"Philipp Lehmann<br>"
"testing and bug reporting"
"<hr>"
"Markku Hinhala<br>"
"Author of kdvi 0.4.3"
"<hr>"
"Nicolai Langfeldt<br>"
"Maintainer of xdvik"
"<hr>"
"Paul Vojta<br>"
" Author of xdvi<br>"
"<hr>"
"Many others. Really, lots of people who were involved in kdvi, xdvik and "
"xdvi. I apologize to those who I did not mention here. Please send me an "
"email if you think your name belongs here."),
true);
ab->setMinimumWidth(500);
ab->show();
}
void KDVIMultiPage::bugform()
{
KAboutData *kab = new KAboutData("kdvi", I18N_NOOP("KDVI"), "1.1", 0, 0, 0, 0, 0);
KBugReport *kbr = new KBugReport(0, true, kab );
kbr->show();
}
void KDVIMultiPage::helpme()
{
kapp->invokeHelp( "", "kdvi" );
}
void KDVIMultiPage::preferencesChanged()
{
#ifdef KDVI_MULTIPAGE_DEBUG
@ -766,13 +705,6 @@ void KDVIMultiPage::showTipOnStart(void)
}
void KDVIMultiPage::guiActivateEvent( KParts::GUIActivateEvent * event )
{
if (event->activated() && url().isEmpty())
emit setWindowCaption( i18n("KDVI") );
}
DocumentWidget* KDVIMultiPage::createDocumentWidget()
{
// TODO: handle different sizes per page.

@ -115,9 +115,6 @@ protected:
//before the timerEvent function.
void timerEvent( QTimerEvent *e );
// Set initial window caption
void guiActivateEvent( KParts::GUIActivateEvent * event );
virtual void reload();
protected slots:
@ -126,11 +123,8 @@ protected slots:
void doExportText();
void doSelectAll();
void doEnableWarnings();
void about();
void helpme();
void bugform();
void preferencesChanged();
void contentsMovingInScrollView(int x, int y);
/** Makes page # pageNr visible, selects the text Elements

@ -27,11 +27,7 @@
</Menu>
<Menu name="help"><text>Help</text>
<Action name="help_tipofday"/>
<Separator/>
<Action name="help_dvi"/>
<Action name="about_kdvi"/>
<Action name="bug_dvi"/>
<Action name="help_tipofday" group="help_top"/>
</Menu>
</MenuBar>

@ -0,0 +1,138 @@
#include <dcopclient.h>
#include <dcopref.h>
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kdebug.h>
#include <kurl.h>
#include <klocale.h>
#include <kaboutdata.h>
#include <qdir.h>
#include <stdlib.h>
#include "kviewshell.h"
static KCmdLineOptions options[] =
{
{ "unique", I18N_NOOP("Check if the file is loaded in another KDVI. If it is, bring up the other KDVI. Otherwise, load the file."), 0 },
{ "paper ", I18N_NOOP("Sets paper size (not implemented at the moment, only for compatibility with lyx)"), 0 },
{ "+file(s)", I18N_NOOP("Files to load"), 0 },
KCmdLineLastOption
};
static const char description[] = I18N_NOOP("A previewer for Device Independent files (DVI files) produced by the TeX typesetting system.");
int main(int argc, char** argv)
{
KAboutData about ("kdvi", I18N_NOOP("KDVI"), "1.2",
description, KAboutData::License_GPL,
"Markku Hinhala, Stephan Kebekus",
I18N_NOOP("Displays Device Independent (DVI) files."
"Based on original code from kdvi version 0.43 and xdvik."));
about.addAuthor ("Stefan Kebekus",
I18N_NOOP("Current Maintainer.\n"
"Major rewrite of version 0.4.3.\n"
"Implementation of hyperlinks. "),
"kebekus@kde.org",
"http://www.mi.uni-koeln.de/~kebekus");
about.addAuthor ("Markku Hinhala",
I18N_NOOP("Author of kdvi 0.4.3"));
about.addAuthor ("Nicolai Langfeldt",
I18N_NOOP("Maintainer of xdvik"));
about.addAuthor ("Paul Vojta",
I18N_NOOP("Author of xdvi"));
about.addCredit ("Philipp Lehmann",
I18N_NOOP("testing and bug reporting."));
KCmdLineArgs::init(argc, argv, &about);
KCmdLineArgs::addCmdLineOptions(options);
KApplication app;
KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
if (args->isSet("unique"))
{
// With --unique, we need 2 arguments.
if (args->count() < 1)
{
args->usage();
exit(-1);
}
// Find the fully qualified file name of the file we are
// loading. Complain, if we are given a URL which does not point
// to a local file.
KURL url(args->url(0));
if (!args->url(0).isValid())
{
kdError(4300) << QString(I18N_NOOP("The URL %1 is not well-formed.")).arg(args->arg(0)) << endl;
return -1;
}
if (!args->url(0).isLocalFile())
{
kdError(4300) << QString(I18N_NOOP("The URL %1 does not point to a local file. You can only specify local "
"files if you are using the '--unique' option.")).arg(args->arg(0)) << endl;
return -1;
}
QString qualPath = QFileInfo(args->url(1).path()).absFilePath();
app.dcopClient()->attach();
// We need to register as "kviewshell" to stay compatible with existing DCOP-skripts.
QCString id = app.dcopClient()->registerAs("unique-kviewshell");
if (id.isNull())
kdError(4300) << "There was an error using dcopClient()->registerAs()." << endl;
QCStringList apps = app.dcopClient()->registeredApplications();
for ( QCStringList::Iterator it = apps.begin(); it != apps.end(); ++it )
{
if ((*it).find("kdvi") == 0)
{
QByteArray data, replyData;
QCString replyType;
QDataStream arg(data, IO_WriteOnly);
bool result;
arg << qualPath.stripWhiteSpace();
if (!app.dcopClient()->call( *it, "kmultipage", "is_file_loaded(QString)", data, replyType, replyData))
kdError(4300) << "There was an error using DCOP." << endl;
else
{
QDataStream reply(replyData, IO_ReadOnly);
if (replyType == "bool")
{
reply >> result;
if (result == true)
{
if (app.dcopClient()->send( *it, "kmultipage", "jumpToReference(QString)", args->url(0).ref()) == true)
{
app.dcopClient()->detach();
return 0;
}
}
}
else
kdError(4300) << "The DCOP function 'doIt' returned an unexpected type of reply!";
}
}
}
}
// We need to register as "kviewshell" to stay compatible with existing DCOP-skripts.
app.dcopClient()->registerAs("kviewshell");
KViewShell* shell = new KViewShell("dvi");
if (args->count() > 0)
shell->openURL(args->url(0));
shell->show();
return app.exec();
}
Loading…
Cancel
Save