summaryrefslogtreecommitdiffstats
path: root/kate/openheader
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit84da08d7b7fcda12c85caeb5a10b4903770a6f69 (patch)
tree2a6aea76f2dfffb4cc04bb907c4725af94f70e72 /kate/openheader
downloadtdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.tar.gz
tdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeaddons@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kate/openheader')
-rw-r--r--kate/openheader/Makefile.am21
-rw-r--r--kate/openheader/kateopenheader.desktop112
-rw-r--r--kate/openheader/plugin_kateopenheader.cpp117
-rw-r--r--kate/openheader/plugin_kateopenheader.h50
-rw-r--r--kate/openheader/ui.rc8
5 files changed, 308 insertions, 0 deletions
diff --git a/kate/openheader/Makefile.am b/kate/openheader/Makefile.am
new file mode 100644
index 0000000..9db3328
--- /dev/null
+++ b/kate/openheader/Makefile.am
@@ -0,0 +1,21 @@
+INCLUDES = $(all_includes)
+METASOURCES = AUTO
+
+# Install this plugin in the KDE modules directory
+kde_module_LTLIBRARIES = kateopenheaderplugin.la
+
+# This is all standard. Remove the LIB_KHTML reference if you are not
+# using the KHTML Part
+kateopenheaderplugin_la_SOURCES = plugin_kateopenheader.cpp
+kateopenheaderplugin_la_LIBADD = -lkateinterfaces
+kateopenheaderplugin_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+
+# Install the .rc file in the Part's directory (in this case, the part
+# is KHTMLPart)
+pluginsdir = $(kde_datadir)/kate/plugins/kateopenheader
+plugins_DATA = ui.rc
+
+kde_services_DATA = kateopenheader.desktop
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp -o $(podir)/kateopenheader.pot
diff --git a/kate/openheader/kateopenheader.desktop b/kate/openheader/kateopenheader.desktop
new file mode 100644
index 0000000..f5f3322
--- /dev/null
+++ b/kate/openheader/kateopenheader.desktop
@@ -0,0 +1,112 @@
+[Desktop Entry]
+Type=Service
+ServiceTypes=Kate/Plugin
+X-KDE-Library=kateopenheaderplugin
+X-Kate-Version=2.5
+Name=Kate OpenHeader
+Name[af]=Kate Maak-opskrif-oop
+Name[cy]=AgorPennawd Kate
+Name[el]=Άνοιγμα επικεφαλίδας του Kate
+Name[eo]=Kodredaktilo-difinmalfermilo
+Name[es]=Cabecera abierta de Kate
+Name[et]=Kate päisefaili avaja
+Name[eu]= Kateren OpenHeader
+Name[fi]=Kate avaaotsikko
+Name[fo]=Kate opna høvd
+Name[fr]=Ouverture d'en-tête pour Kate
+Name[gl]=OpenHeader para Kate
+Name[he]=פותח הכותרות של Kate
+Name[hi]=के-एटीई ओपन-हेडर
+Name[hr]=Kate OtvorenoZaglavlje
+Name[hu]=Kate fejlécmegnyitó
+Name[it]=ApriHeader di Kate
+Name[ja]=Kate オープンヘッダ
+Name[kk]=Kate айдар файлын ашу
+Name[lv]=Kate AtvērtHederi
+Name[nb]=Åpne hodefil i Kate
+Name[nds]=Koppdateien opmaken för Kate
+Name[ne]=केट ओपनहेडर
+Name[pa]=ਕੇਟ ਫਾਇਲ-ਸਿਰਲੇਖ
+Name[pl]=Kate - Otwarcie pliku nagłówkowego
+Name[pt]=OpenHeader do Kate
+Name[pt_BR]=Abrir Cabeçalhos do Kate
+Name[ro]=Includere fişier antet pentru Kate
+Name[ru]=Открытие файла заголовка для Kate
+Name[sr]=Отварање заглавља за Kate
+Name[sr@Latn]=Otvaranje zaglavlja za Kate
+Name[ta]=கேட் திறந்த தலைப்பு
+Name[tg]=Кушодани сарлавҳаи файл барои Kate
+Name[th]=เปิดส่วนหัวของ Kate
+Name[tr]=Kate Başlık Aç
+Name[uk]=Відкрити файл заголовка Kate
+Name[ven]=Kate Openeheda
+Name[vi]=Phần đầu mở Kate
+Name[xh]=Intloko Yokuvula ye Kate
+Name[zu]=u Kate Vula isihloko
+Comment=Opens the corresponding .h/[.cpp|.c] file
+Comment[af]=Maak oop die ooreenstemmend .h/[.cpp|.c] lêer
+Comment[ar]=تفتح ملف .h المقابل لملف [.cpp|.c]
+Comment[az]=Korespond .h/[.cpp|.c] faylını açar
+Comment[bg]=Отваряне на съответстващите файлове .h/[.cpp|.c]
+Comment[bs]=Otvara odgovarajuću .h/[.cpp|.c] datoteku
+Comment[ca]=Obre el corresponent fitxer .h/[.cpp|.c]
+Comment[cs]=Otevře odpovídající soubor .h/[.cpp|.c]
+Comment[cy]=Agor y ffeil .h/[.cpp|.c] addas
+Comment[da]=Åbner den tilsvarende .h/[.cpp|.c]-fil
+Comment[de]=Öffnet die entsprechende .h/[.cpp|.c]-Datei
+Comment[el]=Ανοίγει το αντίστοιχο αρχείο .h/[.cpp|.c]
+Comment[eo]=Malfermas la koncernan .h/[.cpp|.c]-dosieron
+Comment[es]=Abre el archivo .h/[.cpp|.c]
+Comment[et]=Vastava .h/[.cpp|.c] faili avamine
+Comment[eu]= Dagokion .h/[.cpp|.c] fitxategia irekitzen du
+Comment[fa]=پروندۀ متناظر .h/[.cpp|.c] را باز می‌کند.
+Comment[fi]=Avaa vastaavan .h/[.cpp|.c] tiedoston
+Comment[fo]=Opnar tann samsvarandi .h/[.cpp|.c]-fíla.
+Comment[fr]=Ouvre le fichier correspondant .h/[.cpp|.c]
+Comment[fy]=iepent de korrespondearjende .h/[.cpp|.c]-triem
+Comment[ga]=Oscail an comhad .h/[.cpp|.c] a fhreagraíonn leis an gceann seo
+Comment[gl]=Abre o ficheiro .h/[.cpp|.c] correspondente
+Comment[he]=פתיחת קובץ הכותרת המתאים [h/[.cpp|.c.
+Comment[hi]= .h/[.cpp|.c] के सदृश्य फ़ाइल खोलता है
+Comment[hr]=Otvaranje odgovarajuće .h/[.cpp|.c] datoteke
+Comment[hu]=A megfelelő .h/[.cpp|.c] fájl megnyitása
+Comment[is]=Opnar viðkomandi .h/[.cpp|.c] skrá
+Comment[it]=Apre il file .h/[.cpp|.c] corrispondente
+Comment[ja]=対応する .h/[.cpp|.c] ファイルを開きます
+Comment[ka]=ხსნის შესაბამის .h/[.cpp|.c] ფაილს
+Comment[kk]=Керек .h/[.cpp|.c] айдар файлын ашады
+Comment[km]=បើក​ការ​ទាក់ទង​ឯកសារ .h/[.cpp|.c]
+Comment[lt]=Atveria atitinkamą .h/[.cpp|.c] bylą
+Comment[lv]=Atver atbilstošo .h/[.cpp|.c] failu
+Comment[mk]=Ја отвора соодветната .h/[.cpp|.c] датотека
+Comment[ms]=Membuka fail .h/[.cpp|.c] yang sepadan.
+Comment[mt]=Jiftaħ il-fajl .h/[.cpp|.c] li jikkorrispondi
+Comment[nb]=Åpner den tilhørende .h/[.cpp|.c]-fila
+Comment[nds]=Maakt de tohören .h/[.cpp|.c]-Datei op
+Comment[ne]=सङ्गत .h/[.cpp|.c] फाइल खोल्दछ
+Comment[nl]=Opent het corresponderende .h/[.cpp|.c]-bestand
+Comment[nn]=Opnar .h/[.cpp|.c]-fila som høyrer til
+Comment[pa]=ਅਨੁਸਾਰੀ .h/[.cpp|.c] ਫਾਇਲ ਖੋਲੋ
+Comment[pl]=Otwiera odpowiadający plik h/[.cpp|.c]
+Comment[pt]=Abre o ficheiro .h/[.cpp|.c] correspondente
+Comment[pt_BR]=Abrir o arquivo .h[cpp|.c] correspondente
+Comment[ro]=Deschide fişierul antet corespunzător .h/[.cpp|.c]
+Comment[ru]=Открывает соответствующий файл .h/[.cpp|.c]
+Comment[sk]=Otvorí odpovedajúci súbor .h/[.cpp|.c]
+Comment[sl]=Odpre pripadajočo datoteko .h/[.cpp|.c]
+Comment[sr]=Отвара одговарајући .h/[.cpp|.c] фајл
+Comment[sr@Latn]=Otvara odgovarajući .h/[.cpp|.c] fajl
+Comment[sv]=Öppnar den motsvarande .h/[.cpp|.c]-filen
+Comment[ta]=தொடர்புடைய .h/[.cpp|.c] கோப்பினைத் திறக்கிறது
+Comment[tg]=Файли мувофиқи .h/[.cpp|.c] мекушояд
+Comment[th]=เปิดแฟ้มที่มีรูปแบบ .h/[.cpp|.c]
+Comment[tr]=.h/[.cpp|.c] dosyasını açar
+Comment[uk]=Відкриває відповідний файл .h/[.cpp|.c]
+Comment[uz]=Tegishli .h/[.cpp|.c] faylini ochish
+Comment[uz@cyrillic]=Тегишли .h/[.cpp|.c] файлини очиш
+Comment[ven]=Tshi vula faele dzino yelana .h/[.cpp|.c]
+Comment[vi]=Mở tập tin .h/[.cpp|.c] tương ứng
+Comment[xh]=Ivula ungqamano .h/[.cpp|.c] file
+Comment[zh_CN]=打开相应的 .h/[.cpp|.c] 文件
+Comment[zh_TW]=開啟相對應的 .h/[.cpp|.c] 檔案
+Comment[zu]=Ivula ifayela evumelenayo .h/[.cpp|.c]
diff --git a/kate/openheader/plugin_kateopenheader.cpp b/kate/openheader/plugin_kateopenheader.cpp
new file mode 100644
index 0000000..f404022
--- /dev/null
+++ b/kate/openheader/plugin_kateopenheader.cpp
@@ -0,0 +1,117 @@
+/***************************************************************************
+ plugin_katetextfilter.cpp - description
+ -------------------
+ begin : FRE Feb 23 2001
+ copyright : (C) 2001 by Joseph Wenninger
+ email : jowenn@bigfoot.com
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "plugin_kateopenheader.h"
+#include "plugin_kateopenheader.moc"
+
+#include <qfileinfo.h>
+#include <kgenericfactory.h>
+#include <kaction.h>
+#include <klocale.h>
+#include <kdebug.h>
+#include <kurl.h>
+#include <kio/netaccess.h>
+
+class PluginView : public KXMLGUIClient
+{
+ friend class PluginKateOpenHeader;
+
+ public:
+ Kate::MainWindow *win;
+};
+
+K_EXPORT_COMPONENT_FACTORY( kateopenheaderplugin, KGenericFactory<PluginKateOpenHeader>( "kateopenheader" ) )
+
+PluginKateOpenHeader::PluginKateOpenHeader( QObject* parent, const char* name, const QStringList& )
+ : Kate::Plugin ( (Kate::Application *)parent, name )
+{
+}
+
+PluginKateOpenHeader::~PluginKateOpenHeader()
+{
+}
+
+void PluginKateOpenHeader::addView(Kate::MainWindow *win)
+{
+ // TODO: doesn't this have to be deleted?
+ PluginView *view = new PluginView ();
+
+ (void) new KAction( i18n("Open .h/.cpp/.c"), Key_F12,
+ this, SLOT( slotOpenHeader() ),
+ view->actionCollection(), "file_openheader" );
+
+ view->setInstance (new KInstance("kate"));
+ view->setXMLFile( "plugins/kateopenheader/ui.rc" );
+ win->guiFactory()->addClient (view);
+ view->win = win;
+
+ m_views.append (view);
+}
+
+void PluginKateOpenHeader::removeView(Kate::MainWindow *win)
+{
+ for (uint z=0; z < m_views.count(); z++)
+ if (m_views.at(z)->win == win)
+ {
+ PluginView *view = m_views.at(z);
+ m_views.remove (view);
+ win->guiFactory()->removeClient (view);
+ delete view;
+ }
+}
+
+void PluginKateOpenHeader::slotOpenHeader ()
+{
+ if (!application()->activeMainWindow())
+ return;
+
+ Kate::View * kv (application()->activeMainWindow()->viewManager()->activeView());
+ if (!kv) return;
+
+ KURL url=kv->document()->url();
+ if ((!url.isValid()) || (url.isEmpty())) return;
+
+ QFileInfo info( url.path() );
+ QString extension = info.extension().lower();
+
+ QStringList headers( QStringList() << "h" << "H" << "hh" << "hpp" );
+ QStringList sources( QStringList() << "c" << "cpp" << "cc" << "cp" << "cxx" );
+
+ if( sources.find( extension ) != sources.end() ) {
+ tryOpen( url, headers );
+ } else if ( headers.find( extension ) != headers.end() ) {
+ tryOpen( url, sources );
+ }
+}
+
+void PluginKateOpenHeader::tryOpen( const KURL& url, const QStringList& extensions )
+{
+ if (!application()->activeMainWindow())
+ return;
+
+ kdDebug() << "Trying to open " << url.prettyURL() << " with extensions " << extensions.join(" ") << endl;
+ QString basename = QFileInfo( url.path() ).baseName();
+ KURL newURL( url );
+ for( QStringList::ConstIterator it = extensions.begin(); it != extensions.end(); ++it ) {
+ newURL.setFileName( basename + "." + *it );
+ if( KIO::NetAccess::exists( newURL ) )
+ application()->activeMainWindow()->viewManager()->openURL( newURL );
+ newURL.setFileName( basename + "." + (*it).upper() );
+ if( KIO::NetAccess::exists( newURL ) )
+ application()->activeMainWindow()->viewManager()->openURL( newURL );
+ }
+}
diff --git a/kate/openheader/plugin_kateopenheader.h b/kate/openheader/plugin_kateopenheader.h
new file mode 100644
index 0000000..61b6058
--- /dev/null
+++ b/kate/openheader/plugin_kateopenheader.h
@@ -0,0 +1,50 @@
+ /***************************************************************************
+ plugin_katetextfilter.h - description
+ -------------------
+ begin : FRE Feb 23 2001
+ copyright : (C) 2001 by Joseph Wenninger
+ email : jowenn@bigfoot.com
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef _PLUGIN_KANT_HEADER_H
+#define _PLUGIN_KANT_HEADER_H
+
+#include <qstring.h>
+
+#include <kate/plugin.h>
+#include <kate/application.h>
+#include <kate/view.h>
+#include <kate/document.h>
+#include <kate/documentmanager.h>
+#include <kate/mainwindow.h>
+#include <kate/viewmanager.h>
+
+class PluginKateOpenHeader : public Kate::Plugin, Kate::PluginViewInterface
+{
+ Q_OBJECT
+
+ public:
+ PluginKateOpenHeader( QObject* parent = 0, const char* name = 0, const QStringList& = QStringList() );
+ virtual ~PluginKateOpenHeader();
+
+ void addView (Kate::MainWindow *win);
+ void removeView (Kate::MainWindow *win);
+
+ public slots:
+ void slotOpenHeader ();
+ void tryOpen( const KURL& url, const QStringList& extensions );
+
+ private:
+ QPtrList<class PluginView> m_views;
+};
+
+#endif // _PLUGIN_KANT_OPENHEADER_H
diff --git a/kate/openheader/ui.rc b/kate/openheader/ui.rc
new file mode 100644
index 0000000..5ccd8f8
--- /dev/null
+++ b/kate/openheader/ui.rc
@@ -0,0 +1,8 @@
+<!DOCTYPE kpartgui>
+<kpartplugin name="kateopenheader" library="libkateopenheaderplugin" version="3">
+<MenuBar>
+ <Menu name="file"><Text>&amp;File</Text>
+ <Action name="file_openheader" group="open_merge"/>
+ </Menu>
+</MenuBar>
+</kpartplugin>