From 2b088a31e6bfba86a1a20109bb5b57cb369c6b3c Mon Sep 17 00:00:00 2001 From: tarek_saidi Date: Sat, 28 Oct 2006 18:50:37 +0000 Subject: [PATCH] added plugin for gnome/gtk integration git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@111 b624d157-de02-0410-bad0-e51aec6abb33 --- src/main.cpp | 14 +++++ src/plugins/gnome/keepassx-gnome.cpp | 83 ++++++++++++++++++++++++++++ src/plugins/gnome/keepassx-gnome.h | 38 +++++++++++++ src/plugins/gnome/keepassx-gnome.pro | 16 ++++++ src/plugins/interfaces/IFileDialog.h | 31 +++++++++++ src/src.pro | 3 +- 6 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 src/plugins/gnome/keepassx-gnome.cpp create mode 100644 src/plugins/gnome/keepassx-gnome.h create mode 100644 src/plugins/gnome/keepassx-gnome.pro create mode 100644 src/plugins/interfaces/IFileDialog.h diff --git a/src/main.cpp b/src/main.cpp index ad19342..9b30ddc 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,6 +30,9 @@ #include #include #include +#include + +#include "plugins/interfaces/IFileDialog.h" #include "main.h" #include "PwmConfig.h" @@ -87,6 +90,17 @@ QApplication* app=new QApplication(argc,argv); QString ArgFile,ArgCfg,ArgLang,IniFilename; parseCmdLineArgs(argc,argv,ArgFile,ArgCfg,ArgLang); AppDir=app->applicationDirPath(); + +/* + +QPluginLoader gtkplugin("/home/tarek/Documents/KeePassX/src/plugins/gnome/libkeepassx-gnome.so"); +if(!gtkplugin.load()) + qDebug(gtkplugin.errorString().toUtf8().data()); +IFileDialog* filedlg=qobject_cast(gtkplugin.instance()); +showErrMsg(filedlg->openExistingFileDialog(NULL,"Hallo","/home",QStringList()<<"Images (*.jpg *.bmp *.jpeg *.png)"<<"Text Files (*.txt *.rtf)"<<"All files (*)")); +return 0; +*/ + //Load Config if(ArgCfg==QString()){ if(!QDir(QDir::homePath()+"/.keepass").exists()){ diff --git a/src/plugins/gnome/keepassx-gnome.cpp b/src/plugins/gnome/keepassx-gnome.cpp new file mode 100644 index 0000000..f47ce8e --- /dev/null +++ b/src/plugins/gnome/keepassx-gnome.cpp @@ -0,0 +1,83 @@ +/*************************************************************************** + * Copyright (C) 2005-2006 by Tarek Saidi * + * tarek.saidi@arcor.de * + * * + * 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. * + * * + * 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; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include +#include "keepassx-gnome.h" +#define CSTRING(x)(x.toUtf8().data()) + +Q_EXPORT_PLUGIN2(keepassx_gnome, GnomePlugin) + +QString GnomePlugin::openExistingFileDialog(QWidget* parent,QString title,QString dir, + QStringList Filters){ + + GtkWidget *FileDlg; + QString filename; + gtk_init(0,0); + FileDlg=gtk_file_chooser_dialog_new(title.toUtf8().data(),NULL, + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(FileDlg),dir.toUtf8().data()); + GtkFileFilter** filters=parseFilterStrings(Filters); + + for(int i=0;i +#include +#include +#include "../interfaces/IFileDialog.h" + + +class GnomePlugin:public QObject,public IFileDialog{ + Q_OBJECT + Q_INTERFACES(IFileDialog) + public: + virtual QString openExistingFileDialog(QWidget* parent,QString title,QString dir, + QStringList Filters); + virtual QString saveFileDialog(QWidget* parent,QString title,QString dir, + QStringList Filters); + private: + GtkFileFilter** parseFilterStrings(const QStringList &Filters); +}; diff --git a/src/plugins/gnome/keepassx-gnome.pro b/src/plugins/gnome/keepassx-gnome.pro new file mode 100644 index 0000000..d7309f0 --- /dev/null +++ b/src/plugins/gnome/keepassx-gnome.pro @@ -0,0 +1,16 @@ + +INCLUDEPATH += /opt/gnome/include/gtk-2.0 \ + /opt/gnome/include/glib-2.0 \ + /opt/gnome/include/pango-1.0 \ + /opt/gnome/include/atk-1.0 \ + /opt/gnome/include/orbit-2.0 \ + /usr/include/cairo \ + /opt/gnome/lib/glib-2.0/include \ + /opt/gnome/lib/gtk-2.0/include +TEMPLATE = lib +CONFIG += plugin release +HEADERS += keepassx-gnome.h +SOURCES += keepassx-gnome.cpp +MOC_DIR = build/moc +OBJECTS_DIR = build/ +LIBS+=-lgtk-x11-2.0 \ No newline at end of file diff --git a/src/plugins/interfaces/IFileDialog.h b/src/plugins/interfaces/IFileDialog.h new file mode 100644 index 0000000..7c6cc59 --- /dev/null +++ b/src/plugins/interfaces/IFileDialog.h @@ -0,0 +1,31 @@ +/*************************************************************************** + * Copyright (C) 2005-2006 by Tarek Saidi * + * tarek.saidi@arcor.de * + * * + * 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. * + * * + * 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; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include + +class IFileDialog{ + public: + virtual ~IFileDialog(){} + virtual QString openExistingFileDialog(QWidget* parent,QString title,QString dir, + QStringList Filters)=0; + virtual QString saveFileDialog(QWidget* parent,QString title,QString dir, + QStringList Filters)=0; +}; +Q_DECLARE_INTERFACE(IFileDialog,"org.KeePassX.FileDialogInterface/1.0") \ No newline at end of file diff --git a/src/src.pro b/src/src.pro index dc60123..619949c 100755 --- a/src/src.pro +++ b/src/src.pro @@ -88,7 +88,8 @@ HEADERS += lib/IniReader.h \ crypto/aescpp.h \ crypto/sha256.h \ crypto/yarrow.h \ - lib/WaitAnimationWidget.h + lib/WaitAnimationWidget.h \ + plugins/interfaces/IFileDialog.h SOURCES += lib/IniReader.cpp \ lib/UrlLabel.cpp \ main.cpp \