git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@111 b624d157-de02-0410-bad0-e51aec6abb33master
parent
b9feb0b74d
commit
2b088a31e6
@ -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 <gtk/gtk.h> |
||||||
|
#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<Filters.size();i++){
|
||||||
|
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(FileDlg),filters[i]); |
||||||
|
} |
||||||
|
if (gtk_dialog_run(GTK_DIALOG(FileDlg)) == GTK_RESPONSE_ACCEPT){ |
||||||
|
char* filename_cstring=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(FileDlg)); |
||||||
|
filename = QString::fromUtf8(filename_cstring); |
||||||
|
g_free(filename_cstring); |
||||||
|
} |
||||||
|
gtk_widget_destroy (FileDlg); |
||||||
|
return filename; |
||||||
|
} |
||||||
|
|
||||||
|
GtkFileFilter** GnomePlugin::parseFilterStrings(const QStringList& filters){ |
||||||
|
if(!filters.size())return NULL; |
||||||
|
GtkFileFilter **f=new GtkFileFilter*[filters.size()]; |
||||||
|
for(int i=0;i<filters.size();i++){ |
||||||
|
f[i]=gtk_file_filter_new(); |
||||||
|
QString name; |
||||||
|
int p=0; |
||||||
|
for(p;p<filters[i].size();p++){ |
||||||
|
if(filters[i][p]!='(') |
||||||
|
name += filters[i][p]; |
||||||
|
else |
||||||
|
break;
|
||||||
|
} |
||||||
|
gtk_file_filter_set_name(f[i],CSTRING(name)); |
||||||
|
p++; |
||||||
|
QString pattern; |
||||||
|
for(p;p<filters[i].size()-1;p++){ |
||||||
|
if(filters[i][p]==' '){ |
||||||
|
gtk_file_filter_add_pattern(f[i],CSTRING(pattern)); |
||||||
|
pattern=QString(); |
||||||
|
} |
||||||
|
else{ |
||||||
|
pattern += filters[i][p];
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
return f; |
||||||
|
} |
||||||
|
|
||||||
|
QString GnomePlugin::saveFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters){return QString();} |
@ -0,0 +1,38 @@ |
|||||||
|
/***************************************************************************
|
||||||
|
* 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 <gtk/gtk.h> |
||||||
|
#include <QtPlugin> |
||||||
|
#include <QObject> |
||||||
|
#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); |
||||||
|
}; |
@ -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 |
@ -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 <QString> |
||||||
|
#include <QStringList> |
||||||
|
|
||||||
|
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") |
Reference in new issue