Fixed Gtk plugin crash
git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@117 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
@@ -23,12 +23,17 @@
|
||||
#define CSTR(x)(x.toUtf8().data())
|
||||
|
||||
Q_EXPORT_PLUGIN2(keepassx_gnome, GnomePlugin)
|
||||
|
||||
bool GnomePlugin::init(int argc, char** argv){
|
||||
int t_argc=argc;
|
||||
char** t_argv=argv;
|
||||
return gtk_init_check(&t_argc,&t_argv);
|
||||
}
|
||||
|
||||
QString GnomePlugin::openExistingFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters){
|
||||
unsigned int NumFilters=Filters.size();
|
||||
GtkWidget *FileDlg;
|
||||
QString filename;
|
||||
gtk_init(0,0);
|
||||
FileDlg=gtk_file_chooser_dialog_new(CSTR(title),NULL,
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
@@ -68,7 +73,6 @@ GtkFileFilter** GnomePlugin::parseFilterStrings(const QStringList& filters){
|
||||
for(p;p<filters[i].size();p++){
|
||||
if(filters[i][p]==' ' || filters[i][p]==')'){
|
||||
gtk_file_filter_add_pattern(f[i],CSTR(pattern));
|
||||
qDebug(CSTR(pattern));
|
||||
pattern=QString();
|
||||
}
|
||||
else{
|
||||
@@ -84,7 +88,6 @@ QStringList GnomePlugin::openExistingFilesDialog(QWidget* parent,QString title,Q
|
||||
unsigned int NumFilters=Filters.size();
|
||||
GtkWidget *FileDlg;
|
||||
QStringList filenames;
|
||||
gtk_init(0,0);
|
||||
FileDlg=gtk_file_chooser_dialog_new(CSTR(title),NULL,
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
|
||||
@@ -23,11 +23,12 @@
|
||||
#include <QtPlugin>
|
||||
#include <QObject>
|
||||
#include "../interfaces/IFileDialog.h"
|
||||
#include "../interfaces/IGnomeInit.h"
|
||||
|
||||
|
||||
class GnomePlugin:public QObject,public IFileDialog{
|
||||
class GnomePlugin:public QObject,public IFileDialog,public IGnomeInit{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(IFileDialog)
|
||||
Q_INTERFACES(IGnomeInit)
|
||||
public:
|
||||
virtual QString openExistingFileDialog(QWidget* parent,QString title,QString dir,
|
||||
QStringList Filters);
|
||||
@@ -35,6 +36,7 @@ class GnomePlugin:public QObject,public IFileDialog{
|
||||
QStringList Filters);
|
||||
virtual QString saveFileDialog(QWidget* parent,QString title,QString dir,
|
||||
QStringList Filters,bool ShowOverwriteWarning=true);
|
||||
virtual bool init(int argc, char** argv);
|
||||
private:
|
||||
GtkFileFilter** parseFilterStrings(const QStringList &Filters);
|
||||
};
|
||||
};
|
||||
34
src/plugins/interfaces/IGnomeInit.h
Normal file
34
src/plugins/interfaces/IGnomeInit.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/***************************************************************************
|
||||
* 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>
|
||||
#include <QApplication>
|
||||
|
||||
#ifndef _I_GNOME_INIT_H_
|
||||
#define _I_GNOME_INIT_H_
|
||||
|
||||
class IGnomeInit{
|
||||
public:
|
||||
virtual ~IGnomeInit(){}
|
||||
virtual bool init(int argc, char** argv)=0;
|
||||
};
|
||||
Q_DECLARE_INTERFACE(IGnomeInit,"org.KeePassX.GnomeInitInterface/1.0")
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user