summaryrefslogtreecommitdiffstats
path: root/kdesktop/kwebdesktop
diff options
context:
space:
mode:
Diffstat (limited to 'kdesktop/kwebdesktop')
-rw-r--r--kdesktop/kwebdesktop/CMakeLists.txt42
-rw-r--r--kdesktop/kwebdesktop/Makefile.am15
-rw-r--r--kdesktop/kwebdesktop/kwebdesktop.cpp193
-rw-r--r--kdesktop/kwebdesktop/kwebdesktop.desktop80
-rw-r--r--kdesktop/kwebdesktop/kwebdesktop.h70
-rw-r--r--kdesktop/kwebdesktop/kwebdesktop.kcfg19
-rw-r--r--kdesktop/kwebdesktop/kwebdesktopsettings.kcfgc4
7 files changed, 423 insertions, 0 deletions
diff --git a/kdesktop/kwebdesktop/CMakeLists.txt b/kdesktop/kwebdesktop/CMakeLists.txt
new file mode 100644
index 000000000..741b8df34
--- /dev/null
+++ b/kdesktop/kwebdesktop/CMakeLists.txt
@@ -0,0 +1,42 @@
+#################################################
+#
+# (C) 2010-2011 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}
+ ${TDE_INCLUDE_DIR}
+ ${TQT_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+
+##### other data ################################
+
+install( FILES kwebdesktop.desktop DESTINATION ${DATA_INSTALL_DIR}/kdesktop/programs )
+install( FILES kwebdesktop.kcfg DESTINATION ${KCFG_INSTALL_DIR} )
+
+
+##### kwebdesktop (executable) ##################
+
+set( target kwebdesktop )
+
+set( ${target}_SRCS
+ kwebdesktop.cpp kwebdesktopsettings.kcfgc
+)
+
+tde_add_executable( ${target} AUTOMOC
+ SOURCES ${${target}_SRCS}
+ LINK tdehtml-shared
+ DESTINATION ${BIN_INSTALL_DIR}
+)
diff --git a/kdesktop/kwebdesktop/Makefile.am b/kdesktop/kwebdesktop/Makefile.am
new file mode 100644
index 000000000..0d627675f
--- /dev/null
+++ b/kdesktop/kwebdesktop/Makefile.am
@@ -0,0 +1,15 @@
+
+INCLUDES= $(all_includes)
+LDADD = $(LIB_TDEHTML)
+
+bin_PROGRAMS = kwebdesktop
+
+METASOURCES = AUTO
+
+kwebdesktop_SOURCES = kwebdesktop.cpp kwebdesktopsettings.kcfgc
+kwebdesktop_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor
+
+kdesktop_kwebdesktop_data_DATA = kwebdesktop.desktop
+kdesktop_kwebdesktop_datadir = $(kde_datadir)/kdesktop/programs
+
+kde_kcfg_DATA = kwebdesktop.kcfg
diff --git a/kdesktop/kwebdesktop/kwebdesktop.cpp b/kdesktop/kwebdesktop/kwebdesktop.cpp
new file mode 100644
index 000000000..1e2499ea2
--- /dev/null
+++ b/kdesktop/kwebdesktop/kwebdesktop.cpp
@@ -0,0 +1,193 @@
+/* This file is part of the KDE project
+ Copyright (C) 2000 David Faure <[email protected]>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+// Idea by Gael Duval
+// Implementation by David Faure
+
+#include <config.h>
+
+#include <tdeapplication.h>
+#include <tdeconfig.h>
+#include <kdebug.h>
+#include <tdelocale.h>
+#include <tdecmdlineargs.h>
+#include <tdeaboutdata.h>
+#include <kurifilter.h>
+#include <tdeio/job.h>
+
+#include <tqscrollview.h>
+#include "kwebdesktop.h"
+#include <kmimetype.h>
+#include <tdeparts/componentfactory.h>
+#include "kwebdesktopsettings.h"
+
+#include "kwebdesktop.moc"
+
+static TDECmdLineOptions options[] =
+{
+ { "+width", I18N_NOOP("Width of the image to create"), 0 },
+ { "+height", I18N_NOOP("Height of the image to create"), 0 },
+ { "+file", I18N_NOOP("File sname where to dump the output in png format"), 0 },
+ { "+[URL]", I18N_NOOP("URL to open (if not specified, it is read from kwebdesktoprc)"), 0 },
+ TDECmdLineLastOption
+};
+
+KWebDesktopRun::KWebDesktopRun( KWebDesktop* webDesktop, const KURL & url )
+ : m_webDesktop(webDesktop), m_url(url)
+{
+ kdDebug() << "KWebDesktopRun::KWebDesktopRun starting get" << endl;
+ TDEIO::Job * job = TDEIO::get(m_url, false, false);
+ connect( job, TQT_SIGNAL( result( TDEIO::Job *)),
+ this, TQT_SLOT( slotFinished(TDEIO::Job *)));
+ connect( job, TQT_SIGNAL( mimetype( TDEIO::Job *, const TQString &)),
+ this, TQT_SLOT( slotMimetype(TDEIO::Job *, const TQString &)));
+}
+
+void KWebDesktopRun::slotMimetype( TDEIO::Job *job, const TQString &_type )
+{
+ TDEIO::SimpleJob *sjob = static_cast<TDEIO::SimpleJob *>(job);
+ // Update our URL in case of a redirection
+ m_url = sjob->url();
+ TQString type = _type; // necessary copy if we plan to use it
+ sjob->putOnHold();
+ kdDebug() << "slotMimetype : " << type << endl;
+
+ KParts::ReadOnlyPart* part = m_webDesktop->createPart( type );
+ // Now open the URL in the part
+ if ( part )
+ part->openURL( m_url );
+}
+
+void KWebDesktopRun::slotFinished( TDEIO::Job * job )
+{
+ // The whole point of all this is to abort silently on error
+ if (job->error())
+ {
+ kdDebug() << job->errorString() << endl;
+ kapp->exit(1);
+ }
+}
+
+
+int main( int argc, char **argv )
+{
+ TDEAboutData data( "kwebdesktop", I18N_NOOP("TDE Web Desktop"),
+ VERSION,
+ I18N_NOOP("Displays an HTML page as the background of the desktop"),
+ TDEAboutData::License_GPL,
+ "(c) 2000, David Faure <[email protected]>" );
+ data.addAuthor( "David Faure", I18N_NOOP("developer and maintainer"), "[email protected]" );
+
+ TDECmdLineArgs::init( argc, argv, &data );
+
+ TDECmdLineArgs::addCmdLineOptions( options ); // Add our own options.
+
+ TDEApplication app;
+
+ TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
+ if ( args->count() != 3 && args->count() != 4 )
+ {
+ args->usage();
+ return 1;
+ }
+ const int width = TQCString(args->arg(0)).toInt();
+ const int height = TQCString(args->arg(1)).toInt();
+ TQCString imageFile = args->arg(2);
+ TQString url;
+ if (args->count() == 4)
+ url = TQString::fromLocal8Bit(args->arg(3));
+
+ KWebDesktop *webDesktop = new KWebDesktop( 0, imageFile, width, height );
+
+ if (url.isEmpty())
+ url = KWebDesktopSettings::uRL();
+ // Apply uri filter
+ KURIFilterData uridata = url;
+ KURIFilter::self()->filterURI( uridata );
+ KURL u = uridata.uri();
+
+ // Now start getting, to ensure mimetype and possible connection
+ KWebDesktopRun * run = new KWebDesktopRun( webDesktop, u );
+
+ int ret = app.exec();
+
+ TDEIO::SimpleJob::removeOnHold(); // Kill any slave that was put on hold.
+ delete webDesktop;
+ delete run;
+ //tdehtml::Cache::clear();
+
+ return ret;
+}
+
+void KWebDesktop::slotCompleted()
+{
+ kdDebug() << "KWebDesktop::slotCompleted" << endl;
+ // Dump image to m_imageFile
+ TQPixmap snapshot = TQPixmap::grabWidget( m_part->widget() );
+ snapshot.save( m_imageFile, "PNG" );
+ // And terminate the app.
+ kapp->quit();
+}
+
+KParts::ReadOnlyPart* KWebDesktop::createPart( const TQString& mimeType )
+{
+ delete m_part;
+ m_part = 0;
+
+ KMimeType::Ptr mime = KMimeType::mimeType( mimeType );
+ if ( !mime || mime == KMimeType::defaultMimeTypePtr() )
+ return 0;
+ if ( mime->is( "text/html" ) || mime->is( "text/xml" ) || mime->is( "application/xhtml+xml" ) )
+ {
+ TDEHTMLPart* htmlPart = new TDEHTMLPart;
+ htmlPart->widget()->resize(m_width,m_height);
+
+ htmlPart->setMetaRefreshEnabled(false);
+ htmlPart->setJScriptEnabled(false);
+ htmlPart->setJavaEnabled(false);
+ htmlPart->setPluginsEnabled(false);
+
+ ((TQScrollView *)htmlPart->widget())->setFrameStyle( TQFrame::NoFrame );
+ ((TQScrollView *)htmlPart->widget())->setHScrollBarMode( TQScrollView::AlwaysOff );
+ ((TQScrollView *)htmlPart->widget())->setVScrollBarMode( TQScrollView::AlwaysOff );
+
+ connect( htmlPart, TQT_SIGNAL( completed() ), this, TQT_SLOT( slotCompleted() ) );
+ m_part = htmlPart;
+ } else {
+ // Try to find an appropriate viewer component
+ m_part = KParts::ComponentFactory::createPartInstanceFromQuery<KParts::ReadOnlyPart>
+ ( mimeType, TQString(), 0, 0, this, 0 );
+ if ( !m_part )
+ kdWarning() << "No handler found for " << mimeType << endl;
+ else {
+ kdDebug() << "Loaded " << m_part->className() << endl;
+ connect( m_part, TQT_SIGNAL( completed() ),
+ this, TQT_SLOT( slotCompleted() ) );
+ }
+ }
+ if ( m_part ) {
+ connect( m_part, TQT_SIGNAL( canceled(const TQString &) ),
+ this, TQT_SLOT( slotCompleted() ) );
+ }
+ return m_part;
+}
+
+KWebDesktop::~KWebDesktop()
+{
+ delete m_part;
+}
diff --git a/kdesktop/kwebdesktop/kwebdesktop.desktop b/kdesktop/kwebdesktop/kwebdesktop.desktop
new file mode 100644
index 000000000..a60c009d0
--- /dev/null
+++ b/kdesktop/kwebdesktop/kwebdesktop.desktop
@@ -0,0 +1,80 @@
+[TDE Desktop Program]
+Comment=TDE Web Desktop
+Comment[af]=TDE Web Werkskerm
+Comment[ar]=سطح المكتب TDE للشبكة
+Comment[az]=TDE Veb Masa üstü
+Comment[be]=Працоўны стол Web
+Comment[bn]=কে.ডি.ই. ওয়েব ডেস্কটপ
+Comment[br]=Burev gwiad TDE
+Comment[bs]=TDE Web radna površina
+Comment[ca]=Escriptori Web TDE
+Comment[cs]=Aktivní plocha TDE
+Comment[csb]=Pùlt w sztélu sécë WWW
+Comment[cy]=Penbwrdd Gwe TDE
+Comment[da]=TDE-net-desktop
+Comment[de]=TDE-Web-Arbeitsfläche
+Comment[el]=Επιφάνεια εργασίας Ιστού του TDE
+Comment[eo]=TDEa TTT-tabulo
+Comment[es]=Escritorio Web para TDE
+Comment[et]=TDE veebitöölaud
+Comment[eu]=TDE web mahaigaina
+Comment[fa]=رومیزی وب TDE
+Comment[fi]=TDE:n web-työpöytä
+Comment[fr]=Bureau web de TDE
+Comment[fy]=TDE Web Buroblêd
+Comment[gl]=Escritório Web de TDE
+Comment[he]=שולחן העבודה האינטרנטי של TDE
+Comment[hi]=केडीई वेब डेस्कटॉप
+Comment[hr]=TDE web radna površina
+Comment[hu]=TDE internetes munkaasztal
+Comment[id]=Desktop Web TDE
+Comment[is]=TDE vefskjáborð
+Comment[it]=Desktop Web di TDE
+Comment[ja]=TDE ウェブデスクトップ
+Comment[ka]=TDE ვებ სამუშაო დაფა
+Comment[km]=ផ្ទៃតុ​បណ្ដាញ TDE
+Comment[lo]=ພື້ນທີ່ທຳງານບົນເວ໊ບ TDE
+Comment[lt]=TDE žiniatinklio darbastalis
+Comment[lv]=TDE Web Darbvirsma
+Comment[mk]=TDE веб-површина
+Comment[mn]=КДЭ-Вэб-Ажлын тавцан
+Comment[ms]=Desktop Web TDE
+Comment[mt]=Desktop Web TDE
+Comment[nb]=TDE nettskrivebord
+Comment[nds]=TDE-Nettschriefdisch
+Comment[ne]=TDE वेब डेस्कटप
+Comment[nl]=TDE Web Bureaublad
+Comment[nn]=TDE Vevskrivebord
+Comment[nso]=Desktop ya Web ya TDE
+Comment[oc]=BurèU Web TDE
+Comment[pa]=TDE ਵੈੱਬ ਵੇਹੜਾ
+Comment[pl]=Pulpit w stylu sieci WWW
+Comment[pt]=Ecrã Web do TDE
+Comment[pt_BR]=Área de Trabalho Web do TDE
+Comment[ro]=Ecran web pentru TDE
+Comment[rw]=TDE Ibiro Rubugamakuru
+Comment[se]=TDE Web-čállinbeavdi
+Comment[sk]=TDE Web pracovná plocha
+Comment[sl]=Spletno namizje TDE
+Comment[sr]=TDE веб радна површина
+Comment[sr@Latn]=TDE veb radna površina
+Comment[sv]=TDE-webbskrivbord
+Comment[ta]=TDE வலை மேல்மேசை
+Comment[te]=కెడిఈ వెబ్ రంగస్థలం
+Comment[tg]=Мизи кории TDE Вэб
+Comment[th]=พื้นที่ทำงาน TDE แบบเว็บ
+Comment[tr]=TDE Web Masaüstü
+Comment[tt]=TDE Web Östäl
+Comment[uk]=Стільниця "а ля Web" для TDE
+Comment[uz]=TDE veb-ish stoli
+Comment[uz@cyrillic]=TDE веб-иш столи
+Comment[ven]=Webe ya desikithopo ya TDE
+Comment[vi]=màn hình nền kiểu trang mạng của TDE
+Comment[wa]=Sicribanne waibe TDE
+Comment[zh_CN]=TDE Web 桌面
+Comment[zh_TW]=TDE 網頁桌面
+Comment[zu]=I-Desktop ye-Web ye-TDE
+Executable=kwebdesktop
+Command=kwebdesktop %x %y %f http://www.kde.org/
+PreviewCommand=kwebdesktop %x %y %f http://www.kde.org/
+Refresh=10
diff --git a/kdesktop/kwebdesktop/kwebdesktop.h b/kdesktop/kwebdesktop/kwebdesktop.h
new file mode 100644
index 000000000..2641378cf
--- /dev/null
+++ b/kdesktop/kwebdesktop/kwebdesktop.h
@@ -0,0 +1,70 @@
+/* This file is part of the KDE project
+ Copyright (C) 2000 David Faure <[email protected]>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef KWEBDESKTOP_H
+#define KWEBDESKTOP_H
+
+#include <tqobject.h>
+#include <tqcstring.h>
+#include <tdeparts/browserextension.h>
+#include <tdehtml_part.h>
+
+namespace TDEIO { class Job; }
+
+class KWebDesktop : public TQObject
+{
+ Q_OBJECT
+public:
+ KWebDesktop( TQObject* parent, const TQCString & imageFile, int width, int height )
+ : TQObject( parent ),
+ m_part( 0 ),
+ m_imageFile( imageFile ),
+ m_width( width ),
+ m_height( height ) {}
+ ~KWebDesktop();
+
+ KParts::ReadOnlyPart* createPart( const TQString& mimeType );
+
+private slots:
+ void slotCompleted();
+
+private:
+ KParts::ReadOnlyPart* m_part;
+ TQCString m_imageFile;
+ int m_width;
+ int m_height;
+};
+
+
+class KWebDesktopRun : public QObject
+{
+ Q_OBJECT
+public:
+ KWebDesktopRun( KWebDesktop* webDesktop, const KURL & url );
+ ~KWebDesktopRun() {}
+
+protected slots:
+ void slotMimetype( TDEIO::Job *job, const TQString &_type );
+ void slotFinished( TDEIO::Job * job );
+
+private:
+ KWebDesktop* m_webDesktop;
+ KURL m_url;
+};
+
+#endif
diff --git a/kdesktop/kwebdesktop/kwebdesktop.kcfg b/kdesktop/kwebdesktop/kwebdesktop.kcfg
new file mode 100644
index 000000000..b0920f410
--- /dev/null
+++ b/kdesktop/kwebdesktop/kwebdesktop.kcfg
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ <kcfgfile name="kwebdesktoprc" />
+ <!-- generated by TDEConfig XTraKtor -->
+
+ <group name="Settings">
+ <entry key="URL" type="String">
+ <default>http://www.kde.org/</default>
+ <label></label>
+ <whatsthis></whatsthis>
+ <!-- kdiconview.cc:1103 -->
+ <!-- cfg.readEntry( "URL" ) == "trash:/" ) { -->
+ </entry>
+ </group>
+
+</kcfg>
diff --git a/kdesktop/kwebdesktop/kwebdesktopsettings.kcfgc b/kdesktop/kwebdesktop/kwebdesktopsettings.kcfgc
new file mode 100644
index 000000000..6989a0071
--- /dev/null
+++ b/kdesktop/kwebdesktop/kwebdesktopsettings.kcfgc
@@ -0,0 +1,4 @@
+File=kwebdesktop.kcfg
+ClassName=KWebDesktopSettings
+Singleton=true
+Mutators=true