mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Remove unused gnc_druid code.
Spotted by Robert Fewell. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21799 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
239d2b1069
commit
779fdd045e
@ -44,14 +44,6 @@ libgncmod_app_utils_la_SOURCES = \
|
||||
gnc-accounting-period.c \
|
||||
gnc-addr-quickfill.c \
|
||||
gnc-component-manager.c \
|
||||
gnc-druid.c \
|
||||
gnc-druid-cb.c \
|
||||
gnc-druid-provider.c \
|
||||
gnc-druid-provider-desc.c \
|
||||
gnc-druid-provider-desc-edge.c \
|
||||
gnc-druid-provider-desc-file.c \
|
||||
gnc-druid-provider-desc-multifile.c \
|
||||
gnc-druid-provider-file-cb.c \
|
||||
gnc-entry-quickfill.c \
|
||||
gnc-euro.c \
|
||||
gnc-exp-parser.c \
|
||||
@ -75,14 +67,6 @@ gncinclude_HEADERS = \
|
||||
gnc-accounting-period.h \
|
||||
gnc-addr-quickfill.h \
|
||||
gnc-component-manager.h \
|
||||
gnc-druid.h \
|
||||
gnc-druid-cb.h \
|
||||
gnc-druid-provider.h \
|
||||
gnc-druid-provider-desc.h \
|
||||
gnc-druid-provider-desc-edge.h \
|
||||
gnc-druid-provider-desc-file.h \
|
||||
gnc-druid-provider-desc-multifile.h \
|
||||
gnc-druid-provider-file-cb.h \
|
||||
gnc-entry-quickfill.h \
|
||||
gnc-euro.h \
|
||||
gnc-exp-parser.h \
|
||||
|
@ -1,25 +0,0 @@
|
||||
/********************************************************************\
|
||||
* gnc-druid-cb.c *
|
||||
* *
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include "gnc-druid-cb.h"
|
||||
#include "gnc-basic-gobject.h"
|
||||
|
||||
GNC_BASIC_GOBJECT(GNCDruidCB, GNCDruidCBClass, G_TYPE_OBJECT, NULL, NULL,
|
||||
gnc_druid_cb_get_type, gnc_druid_cb_new)
|
@ -1,65 +0,0 @@
|
||||
/********************************************************************\
|
||||
* gnc-druid-cb.h *
|
||||
* *
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#ifndef GNC_DRUID_CB_H
|
||||
#define GNC_DRUID_CB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
//extern "C" {
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#define G_TYPE_GNC_DRUID_CB gnc_druid_cb_get_type()
|
||||
#define GNC_DRUID_CB(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_GNC_DRUID_CB, GNCDruidCB)
|
||||
#define GNC_DRUID_CB_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_GNC_DRUID_CB, GNCDruidCBClass)
|
||||
#define IS_GNC_DRUID_CB(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_GNC_DRUID_CB)
|
||||
#define IS_GNC_DRUID_CB_CLASS(klass) G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_GNC_DRUID_CB)
|
||||
|
||||
typedef struct _GNCDruidCB GNCDruidCB;
|
||||
typedef struct _GNCDruidCBClass GNCDruidCBClass;
|
||||
|
||||
#include "gnc-druid.h"
|
||||
#include "gnc-druid-provider.h"
|
||||
|
||||
struct _GNCDruidCB
|
||||
{
|
||||
GObject obj;
|
||||
|
||||
GNCDruid* druid_ctx;
|
||||
GNCDruidProvider* prov_ctx;
|
||||
gpointer be_ctx;
|
||||
};
|
||||
|
||||
struct _GNCDruidCBClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
GType gnc_druid_cb_get_type(void);
|
||||
GNCDruidCB* gnc_druid_cb_new(void);
|
||||
|
||||
/* methods */
|
||||
|
||||
#ifdef __cplusplus
|
||||
//}
|
||||
#endif
|
||||
|
||||
#endif /* GNC_DRUID_CB_H */
|
@ -1,105 +0,0 @@
|
||||
/********************************************************************\
|
||||
* gnc-druid-provider-desc-edge.c *
|
||||
* *
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include "gnc-druid-provider-desc-edge.h"
|
||||
#include "gnc-basic-gobject.h"
|
||||
|
||||
static void gnc_druid_provider_desc_edge_class_init (GNCDruidProviderDescEdgeClass *class);
|
||||
static void gnc_druid_provider_desc_edge_init (GNCDruidProviderDescEdge *gspaper);
|
||||
static void gnc_druid_provider_desc_edge_finalize (GObject *obj);
|
||||
|
||||
static GNCDruidProviderDescClass *parent_class;
|
||||
|
||||
GNC_BASIC_GOBJECT(GNCDruidProviderDescEdge, GNCDruidProviderDescEdgeClass,
|
||||
G_TYPE_GNC_DRUID_PROVIDER_DESC,
|
||||
gnc_druid_provider_desc_edge_class_init,
|
||||
gnc_druid_provider_desc_edge_init,
|
||||
gnc_druid_provider_desc_edge_get_type,
|
||||
gnc_druid_provider_desc_edge_new)
|
||||
|
||||
static void
|
||||
gnc_druid_provider_desc_edge_class_init (GNCDruidProviderDescEdgeClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gnc_druid_provider_desc_edge_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_druid_provider_desc_edge_finalize (GObject *obj)
|
||||
{
|
||||
GNCDruidProviderDescEdge *desc = (GNCDruidProviderDescEdge *)obj;
|
||||
|
||||
if (desc->text)
|
||||
g_free(desc->text);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_druid_provider_desc_edge_init (GNCDruidProviderDescEdge *o)
|
||||
{
|
||||
o->parent.name = GNC_DRUID_PROVIDER_TYPE_EDGE;
|
||||
}
|
||||
|
||||
GNCDruidProviderDescEdge*
|
||||
gnc_druid_provider_desc_edge_new_with_data(GNCDruidProviderDescEdgeWhich which,
|
||||
const gchar* title,
|
||||
const gchar* text)
|
||||
{
|
||||
GNCDruidProviderDescEdge* desc;
|
||||
|
||||
desc = gnc_druid_provider_desc_edge_new();
|
||||
g_assert(desc);
|
||||
|
||||
gnc_druid_provider_desc_edge_set_which(desc, which);
|
||||
if (text)
|
||||
gnc_druid_provider_desc_edge_set_text(desc, text);
|
||||
if (title)
|
||||
gnc_druid_provider_desc_set_title(&(desc->parent), title);
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_druid_provider_desc_edge_set_text(GNCDruidProviderDescEdge* desc,
|
||||
const gchar* text)
|
||||
{
|
||||
g_return_if_fail(desc);
|
||||
g_return_if_fail(IS_GNC_DRUID_PROVIDER_DESC_EDGE(desc));
|
||||
g_return_if_fail(text);
|
||||
|
||||
if (desc->text)
|
||||
g_free(desc->text);
|
||||
desc->text = g_strdup(text);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_druid_provider_desc_edge_set_which(GNCDruidProviderDescEdge* desc,
|
||||
GNCDruidProviderDescEdgeWhich which)
|
||||
{
|
||||
g_return_if_fail(desc);
|
||||
g_return_if_fail(IS_GNC_DRUID_PROVIDER_DESC_EDGE(desc));
|
||||
|
||||
desc->first_or_last = which;
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
/********************************************************************\
|
||||
* gnc-druid-provider-desc-edge.h *
|
||||
* *
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#ifndef GNC_DRUID_PROVIDER_DESC_EDGE_H
|
||||
#define GNC_DRUID_PROVIDER_DESC_EDGE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
//extern "C" {
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#define G_TYPE_GNC_DRUID_PROVIDER_DESC_EDGE gnc_druid_provider_desc_edge_get_type()
|
||||
#define GNC_DRUID_PROVIDER_DESC_EDGE(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_GNC_DRUID_PROVIDER_DESC_EDGE, GNCDruidProviderDescEdge)
|
||||
#define IS_GNC_DRUID_PROVIDER_DESC_EDGE(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_GNC_DRUID_PROVIDER_DESC_EDGE)
|
||||
|
||||
typedef struct _GNCDruidProviderDescEdge GNCDruidProviderDescEdge;
|
||||
typedef struct _GNCDruidProviderDescEdgeClass GNCDruidProviderDescEdgeClass;
|
||||
|
||||
#include "gnc-druid.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GNC_DPE_FIRST = 1,
|
||||
GNC_DPE_LAST
|
||||
} GNCDruidProviderDescEdgeWhich;
|
||||
|
||||
#define GNC_DRUID_PROVIDER_TYPE_EDGE "edge"
|
||||
|
||||
struct _GNCDruidProviderDescEdge
|
||||
{
|
||||
GNCDruidProviderDesc parent;
|
||||
|
||||
gchar* text;
|
||||
GNCDruidProviderDescEdgeWhich first_or_last;
|
||||
};
|
||||
|
||||
struct _GNCDruidProviderDescEdgeClass
|
||||
{
|
||||
GNCDruidProviderDescClass parent;
|
||||
};
|
||||
|
||||
GType gnc_druid_provider_desc_edge_get_type(void);
|
||||
GNCDruidProviderDescEdge* gnc_druid_provider_desc_edge_new(void);
|
||||
GNCDruidProviderDescEdge*
|
||||
gnc_druid_provider_desc_edge_new_with_data(GNCDruidProviderDescEdgeWhich,
|
||||
const gchar* title,
|
||||
const gchar* text);
|
||||
|
||||
void gnc_druid_provider_desc_edge_set_text(GNCDruidProviderDescEdge*,
|
||||
const gchar* text);
|
||||
void gnc_druid_provider_desc_edge_set_which(GNCDruidProviderDescEdge*,
|
||||
GNCDruidProviderDescEdgeWhich);
|
||||
|
||||
|
||||
/* methods */
|
||||
|
||||
#ifdef __cplusplus
|
||||
//}
|
||||
#endif
|
||||
|
||||
#endif /* GNC_DRUID_PROVIDER_DESC_EDGE_H */
|
@ -1,136 +0,0 @@
|
||||
/********************************************************************\
|
||||
* gnc-druid-provider-desc-file.c *
|
||||
* *
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include "gnc-druid-provider-desc-file.h"
|
||||
#include "gnc-basic-gobject.h"
|
||||
|
||||
static void gnc_druid_provider_desc_file_class_init (GNCDruidProviderDescFileClass *class);
|
||||
static void gnc_druid_provider_desc_file_init (GNCDruidProviderDescFile *gspaper);
|
||||
static void gnc_druid_provider_desc_file_finalize (GObject *obj);
|
||||
|
||||
static GNCDruidProviderDescClass *parent_class;
|
||||
|
||||
GNC_BASIC_GOBJECT(GNCDruidProviderDescFile, GNCDruidProviderDescFileClass,
|
||||
G_TYPE_GNC_DRUID_PROVIDER_DESC,
|
||||
gnc_druid_provider_desc_file_class_init,
|
||||
gnc_druid_provider_desc_file_init,
|
||||
gnc_druid_provider_desc_file_get_type,
|
||||
gnc_druid_provider_desc_file_new)
|
||||
|
||||
static void
|
||||
gnc_druid_provider_desc_file_class_init (GNCDruidProviderDescFileClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gnc_druid_provider_desc_file_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_druid_provider_desc_file_finalize (GObject *obj)
|
||||
{
|
||||
GNCDruidProviderDescFile *desc = (GNCDruidProviderDescFile *)obj;
|
||||
|
||||
if (desc->text)
|
||||
g_free(desc->text);
|
||||
if (desc->last_dir)
|
||||
g_free(desc->last_dir);
|
||||
if (desc->history_id)
|
||||
g_free(desc->history_id);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_druid_provider_desc_file_init (GNCDruidProviderDescFile *o)
|
||||
{
|
||||
o->parent.name = GNC_DRUID_PROVIDER_TYPE_FILE;
|
||||
}
|
||||
|
||||
GNCDruidProviderDescFile*
|
||||
gnc_druid_provider_desc_file_new_with_data(const gchar* title,
|
||||
const gchar* text,
|
||||
const gchar* history_id,
|
||||
const gchar* last_dir,
|
||||
gboolean glob,
|
||||
GNCDruidProviderCB next_cb,
|
||||
void (*remove_file)(gpointer, gpointer))
|
||||
{
|
||||
GNCDruidProviderDescFile* desc;
|
||||
|
||||
desc = gnc_druid_provider_desc_file_new();
|
||||
g_assert(desc);
|
||||
|
||||
desc->parent.next_cb = next_cb;
|
||||
desc->remove_file = remove_file;
|
||||
desc->glob = glob;
|
||||
|
||||
if (text)
|
||||
gnc_druid_provider_desc_file_set_text(desc, text);
|
||||
if (history_id)
|
||||
gnc_druid_provider_desc_file_set_history_id(desc, history_id);
|
||||
if (last_dir)
|
||||
gnc_druid_provider_desc_file_set_last_dir(desc, last_dir);
|
||||
if (title)
|
||||
gnc_druid_provider_desc_set_title(&(desc->parent), title);
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_druid_provider_desc_file_set_text(GNCDruidProviderDescFile* desc,
|
||||
const gchar* text)
|
||||
{
|
||||
g_return_if_fail(desc);
|
||||
g_return_if_fail(IS_GNC_DRUID_PROVIDER_DESC_FILE(desc));
|
||||
g_return_if_fail(text);
|
||||
|
||||
if (desc->text)
|
||||
g_free(desc->text);
|
||||
desc->text = g_strdup(text);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_druid_provider_desc_file_set_last_dir(GNCDruidProviderDescFile* desc,
|
||||
const gchar* last_dir)
|
||||
{
|
||||
g_return_if_fail(desc);
|
||||
g_return_if_fail(IS_GNC_DRUID_PROVIDER_DESC_FILE(desc));
|
||||
g_return_if_fail(last_dir);
|
||||
|
||||
if (desc->last_dir)
|
||||
g_free(desc->last_dir);
|
||||
desc->last_dir = g_strdup(last_dir);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_druid_provider_desc_file_set_history_id(GNCDruidProviderDescFile* desc,
|
||||
const gchar* history_id)
|
||||
{
|
||||
g_return_if_fail(desc);
|
||||
g_return_if_fail(IS_GNC_DRUID_PROVIDER_DESC_FILE(desc));
|
||||
g_return_if_fail(history_id);
|
||||
|
||||
if (desc->history_id)
|
||||
g_free(desc->history_id);
|
||||
desc->history_id = g_strdup(history_id);
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
/********************************************************************\
|
||||
* gnc-druid-provider-desc-file.h *
|
||||
* *
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#ifndef GNC_DRUID_PROVIDER_DESC_FILE_H
|
||||
#define GNC_DRUID_PROVIDER_DESC_FILE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
//extern "C" {
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#define G_TYPE_GNC_DRUID_PROVIDER_DESC_FILE gnc_druid_provider_desc_file_get_type()
|
||||
#define GNC_DRUID_PROVIDER_DESC_FILE(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_GNC_DRUID_PROVIDER_DESC_FILE, GNCDruidProviderDescFile)
|
||||
#define IS_GNC_DRUID_PROVIDER_DESC_FILE(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_GNC_DRUID_PROVIDER_DESC_FILE)
|
||||
|
||||
typedef struct _GNCDruidProviderDescFile GNCDruidProviderDescFile;
|
||||
typedef struct _GNCDruidProviderDescFileClass GNCDruidProviderDescFileClass;
|
||||
|
||||
#include "gnc-druid.h"
|
||||
#include "gnc-druid-provider-file-cb.h"
|
||||
#include "gnc-druid-provider-desc-multifile.h"
|
||||
|
||||
#define GNC_DRUID_PROVIDER_TYPE_FILE "file"
|
||||
|
||||
struct _GNCDruidProviderDescFile
|
||||
{
|
||||
GNCDruidProviderDesc parent;
|
||||
|
||||
gchar* text;
|
||||
gchar* last_dir;
|
||||
gchar* history_id;
|
||||
gboolean glob;
|
||||
void (*remove_file)(gpointer be_ctx, gpointer file_ctx);
|
||||
|
||||
GNCDruidProviderDescMultifile *multifile_provider;
|
||||
};
|
||||
|
||||
struct _GNCDruidProviderDescFileClass
|
||||
{
|
||||
GNCDruidProviderDescClass parent;
|
||||
};
|
||||
|
||||
GType gnc_druid_provider_desc_file_get_type(void);
|
||||
GNCDruidProviderDescFile* gnc_druid_provider_desc_file_new(void);
|
||||
GNCDruidProviderDescFile*
|
||||
gnc_druid_provider_desc_file_new_with_data(const gchar* title,
|
||||
const gchar* text,
|
||||
const gchar* history_id,
|
||||
const gchar* last_dir,
|
||||
gboolean glob,
|
||||
GNCDruidProviderCB next_cb,
|
||||
void (*remove_file)(gpointer, gpointer));
|
||||
|
||||
void gnc_druid_provider_desc_file_set_text(GNCDruidProviderDescFile*,
|
||||
const gchar* text);
|
||||
void gnc_druid_provider_desc_file_set_last_dir(GNCDruidProviderDescFile*,
|
||||
const gchar* last_dir);
|
||||
void gnc_druid_provider_desc_file_set_history_id(GNCDruidProviderDescFile*,
|
||||
const gchar* history_id);
|
||||
|
||||
/* methods */
|
||||
|
||||
#ifdef __cplusplus
|
||||
//}
|
||||
#endif
|
||||
|
||||
#endif /* GNC_DRUID_PROVIDER_DESC_FILE_H */
|
@ -1,102 +0,0 @@
|
||||
/********************************************************************\
|
||||
* gnc-druid-provider-desc-multifile.c *
|
||||
* *
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include "gnc-druid-provider-desc-multifile.h"
|
||||
#include "gnc-basic-gobject.h"
|
||||
|
||||
static void gnc_druid_provider_desc_multifile_class_init (GNCDruidProviderDescMultifileClass *class);
|
||||
static void gnc_druid_provider_desc_multifile_init (GNCDruidProviderDescMultifile *gspaper);
|
||||
static void gnc_druid_provider_desc_multifile_finalize (GObject *obj);
|
||||
|
||||
static GNCDruidProviderDescClass *parent_class;
|
||||
|
||||
GNC_BASIC_GOBJECT(GNCDruidProviderDescMultifile, GNCDruidProviderDescMultifileClass,
|
||||
G_TYPE_GNC_DRUID_PROVIDER_DESC,
|
||||
gnc_druid_provider_desc_multifile_class_init,
|
||||
gnc_druid_provider_desc_multifile_init,
|
||||
gnc_druid_provider_desc_multifile_get_type,
|
||||
gnc_druid_provider_desc_multifile_new)
|
||||
|
||||
static void
|
||||
gnc_druid_provider_desc_multifile_class_init (GNCDruidProviderDescMultifileClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gnc_druid_provider_desc_multifile_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_druid_provider_desc_multifile_finalize (GObject *obj)
|
||||
{
|
||||
GNCDruidProviderDescMultifile *desc = (GNCDruidProviderDescMultifile *)obj;
|
||||
|
||||
if (desc->text)
|
||||
g_free(desc->text);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_druid_provider_desc_multifile_init (GNCDruidProviderDescMultifile *o)
|
||||
{
|
||||
o->parent.name = GNC_DRUID_PROVIDER_TYPE_MULTIFILE;
|
||||
}
|
||||
|
||||
GNCDruidProviderDescMultifile*
|
||||
gnc_druid_provider_desc_multifile_new_with_data(const gchar* title,
|
||||
const gchar* text,
|
||||
GNCDruidProviderDescFile *file_prov,
|
||||
GNCDruidProviderCB next_cb,
|
||||
GList* (*get_files)(gpointer),
|
||||
const gchar* (*get_filename)(gpointer, gpointer))
|
||||
{
|
||||
GNCDruidProviderDescMultifile* desc;
|
||||
|
||||
desc = gnc_druid_provider_desc_multifile_new();
|
||||
g_assert(desc);
|
||||
|
||||
desc->file_provider = file_prov;
|
||||
desc->get_files = get_files;
|
||||
desc->get_filename = get_filename;
|
||||
desc->parent.next_cb = next_cb;
|
||||
|
||||
if (text)
|
||||
gnc_druid_provider_desc_multifile_set_text(desc, text);
|
||||
if (title)
|
||||
gnc_druid_provider_desc_set_title(&(desc->parent), title);
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_druid_provider_desc_multifile_set_text(GNCDruidProviderDescMultifile* desc,
|
||||
const gchar* text)
|
||||
{
|
||||
g_return_if_fail(desc);
|
||||
g_return_if_fail(IS_GNC_DRUID_PROVIDER_DESC_MULTIFILE(desc));
|
||||
g_return_if_fail(text);
|
||||
|
||||
if (desc->text)
|
||||
g_free(desc->text);
|
||||
desc->text = g_strdup(text);
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
/********************************************************************\
|
||||
* gnc-druid-provider-desc-multifile.h *
|
||||
* *
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#ifndef GNC_DRUID_PROVIDER_DESC_MULTIFILE_H
|
||||
#define GNC_DRUID_PROVIDER_DESC_MULTIFILE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
//extern "C" {
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#define G_TYPE_GNC_DRUID_PROVIDER_DESC_MULTIFILE gnc_druid_provider_desc_multifile_get_type()
|
||||
#define GNC_DRUID_PROVIDER_DESC_MULTIFILE(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_GNC_DRUID_PROVIDER_DESC_MULTIFILE, GNCDruidProviderDescMultifile)
|
||||
#define IS_GNC_DRUID_PROVIDER_DESC_MULTIFILE(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_GNC_DRUID_PROVIDER_DESC_MULTIFILE)
|
||||
|
||||
typedef struct _GNCDruidProviderDescMultifile GNCDruidProviderDescMultifile;
|
||||
typedef struct _GNCDruidProviderDescMultifileClass GNCDruidProviderDescMultifileClass;
|
||||
|
||||
#include "gnc-druid.h"
|
||||
#include "gnc-druid-provider-desc-file.h"
|
||||
|
||||
#define GNC_DRUID_PROVIDER_TYPE_MULTIFILE "multifile"
|
||||
|
||||
struct _GNCDruidProviderDescMultifile
|
||||
{
|
||||
GNCDruidProviderDesc parent;
|
||||
|
||||
gchar* text;
|
||||
GNCDruidProviderDescFile* file_provider;
|
||||
GList* (*get_files)(gpointer be_ctx);
|
||||
const gchar* (*get_filename)(gpointer be_ctx, gpointer file_ctx);
|
||||
};
|
||||
|
||||
struct _GNCDruidProviderDescMultifileClass
|
||||
{
|
||||
GNCDruidProviderDescClass parent;
|
||||
};
|
||||
|
||||
GType gnc_druid_provider_desc_multifile_get_type(void);
|
||||
GNCDruidProviderDescMultifile* gnc_druid_provider_desc_multifile_new(void);
|
||||
GNCDruidProviderDescMultifile*
|
||||
gnc_druid_provider_desc_multifile_new_with_data(const gchar* title,
|
||||
const gchar* text,
|
||||
GNCDruidProviderDescFile *file_prov,
|
||||
GNCDruidProviderCB next_cb,
|
||||
GList* (*get_files)(gpointer),
|
||||
const gchar* (*get_filename)(gpointer, gpointer));
|
||||
|
||||
void gnc_druid_provider_desc_multifile_set_text(GNCDruidProviderDescMultifile*,
|
||||
const gchar* text);
|
||||
|
||||
/* methods */
|
||||
|
||||
#ifdef __cplusplus
|
||||
//}
|
||||
#endif
|
||||
|
||||
#endif /* GNC_DRUID_PROVIDER_DESC_MULTIFILE_H */
|
@ -1,65 +0,0 @@
|
||||
/********************************************************************\
|
||||
* gnc-druid-provider-desc.c *
|
||||
* *
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include "gnc-druid-provider-desc.h"
|
||||
#include "gnc-basic-gobject.h"
|
||||
|
||||
static void gnc_druid_provider_desc_class_init (GNCDruidProviderDescClass *class);
|
||||
static void gnc_druid_provider_desc_finalize (GObject *obj);
|
||||
|
||||
static GObjectClass *parent_class;
|
||||
|
||||
GNC_BASIC_GOBJECT_TYPE(GNCDruidProviderDesc, GNCDruidProviderDescClass,
|
||||
G_TYPE_OBJECT, gnc_druid_provider_desc_class_init, NULL,
|
||||
gnc_druid_provider_desc_get_type)
|
||||
|
||||
static void
|
||||
gnc_druid_provider_desc_class_init (GNCDruidProviderDescClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gnc_druid_provider_desc_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_druid_provider_desc_finalize (GObject *obj)
|
||||
{
|
||||
GNCDruidProviderDesc *desc = (GNCDruidProviderDesc *)obj;
|
||||
|
||||
if (desc->title)
|
||||
g_free(desc->title);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize(obj);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_druid_provider_desc_set_title(GNCDruidProviderDesc* desc, const gchar* title)
|
||||
{
|
||||
g_return_if_fail(desc);
|
||||
g_return_if_fail(IS_GNC_DRUID_PROVIDER_DESC(desc));
|
||||
g_return_if_fail(title);
|
||||
|
||||
if (desc->title)
|
||||
g_free(desc->title);
|
||||
desc->title = g_strdup(title);
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
/********************************************************************\
|
||||
* gnc-druid-provider-desc.h *
|
||||
* *
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#ifndef GNC_DRUID_PROVIDER_DESC_H
|
||||
#define GNC_DRUID_PROVIDER_DESC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
//extern "C" {
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#define G_TYPE_GNC_DRUID_PROVIDER_DESC gnc_druid_provider_desc_get_type()
|
||||
#define GNC_DRUID_PROVIDER_DESC(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_GNC_DRUID_PROVIDER_DESC, GNCDruidProviderDesc)
|
||||
#define GNC_DRUID_PROVIDER_DESC_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_GNC_DRUID_PROVIDER_DESC, GNCDruidProviderDescClass)
|
||||
#define IS_GNC_DRUID_PROVIDER_DESC(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_GNC_DRUID_PROVIDER_DESC)
|
||||
#define IS_GNC_DRUID_PROVIDER_DESC_CLASS(klass) G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_GNC_DRUID_PROVIDER_DESC)
|
||||
|
||||
typedef struct _GNCDruidProviderDesc GNCDruidProviderDesc;
|
||||
typedef struct _GNCDruidProviderDescClass GNCDruidProviderDescClass;
|
||||
|
||||
#include "gnc-druid.h"
|
||||
#include "gnc-druid-provider.h"
|
||||
|
||||
/* return TRUE if the page should be changed, FALSE if it should not */
|
||||
typedef gboolean (*GNCDruidProviderCB)(GNCDruidCB*);
|
||||
|
||||
struct _GNCDruidProviderDesc
|
||||
{
|
||||
GObject obj;
|
||||
const gchar *name; /* the (system-provided)name of this provider */
|
||||
gchar *title; /* the (user-supplied) druid page title */
|
||||
|
||||
/* Some providers require these, but not all. */
|
||||
GNCDruidProviderCB next_cb;
|
||||
GNCDruidProviderCB prev_cb;
|
||||
GNCDruidProviderCB provider_needed;
|
||||
|
||||
/* The following are set internally for use by the backend */
|
||||
GNCDruidProvider * provider; /* a pointer to the provider */
|
||||
};
|
||||
|
||||
struct _GNCDruidProviderDescClass
|
||||
{
|
||||
GObjectClass obj;
|
||||
};
|
||||
|
||||
GType gnc_druid_provider_desc_get_type(void);
|
||||
|
||||
void gnc_druid_provider_desc_set_title(GNCDruidProviderDesc*, const gchar*);
|
||||
|
||||
/* methods */
|
||||
|
||||
#ifdef __cplusplus
|
||||
//}
|
||||
#endif
|
||||
|
||||
#endif /* GNC_DRUID_PROVIDER_DESC_H */
|
@ -1,27 +0,0 @@
|
||||
/********************************************************************\
|
||||
* gnc-druid-provider-file-cb.c *
|
||||
* *
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include "gnc-druid-provider-file-cb.h"
|
||||
#include "gnc-basic-gobject.h"
|
||||
|
||||
GNC_BASIC_GOBJECT(GNCDruidProviderFileCB, GNCDruidProviderFileCBClass,
|
||||
G_TYPE_GNC_DRUID_CB, NULL, NULL,
|
||||
gnc_druid_provider_file_cb_get_type,
|
||||
gnc_druid_provider_file_cb_new)
|
@ -1,64 +0,0 @@
|
||||
/********************************************************************\
|
||||
* gnc-druid-provider-file-cb.h *
|
||||
* *
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#ifndef GNC_DRUID_PROVIDER_FILE_CB_H
|
||||
#define GNC_DRUID_PROVIDER_FILE_CB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
//extern "C" {
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#define G_TYPE_GNC_DRUID_PROVIDER_FILE_CB gnc_druid_provider_file_cb_get_type()
|
||||
#define GNC_DRUID_PROVIDER_FILE_CB(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_GNC_DRUID_PROVIDER_FILE_CB, GNCDruidProviderFileCB)
|
||||
#define GNC_DRUID_PROVIDER_FILE_CB_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_GNC_DRUID_PROVIDER_FILE_CB, GNCDruidProviderFileCBClass)
|
||||
#define IS_GNC_DRUID_PROVIDER_FILE_CB(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_GNC_DRUID_PROVIDER_FILE_CB)
|
||||
#define IS_GNC_DRUID_PROVIDER_FILE_CB_CLASS(klass) G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_GNC_DRUID_PROVIDER_FILE_CB)
|
||||
|
||||
typedef struct _GNCDruidProviderFileCB GNCDruidProviderFileCB;
|
||||
typedef struct _GNCDruidProviderFileCBClass GNCDruidProviderFileCBClass;
|
||||
|
||||
#include "gnc-druid-cb.h"
|
||||
|
||||
struct _GNCDruidProviderFileCB
|
||||
{
|
||||
GNCDruidCB parent;
|
||||
|
||||
const gchar* filename; /* owned by the provider */
|
||||
|
||||
gpointer this_file; /* set by the backend (return to the provider) */
|
||||
};
|
||||
|
||||
struct _GNCDruidProviderFileCBClass
|
||||
{
|
||||
GNCDruidCBClass parent_class;
|
||||
};
|
||||
|
||||
GType gnc_druid_provider_file_cb_get_type(void);
|
||||
GNCDruidProviderFileCB* gnc_druid_provider_file_cb_new(void);
|
||||
|
||||
/* methods */
|
||||
|
||||
#ifdef __cplusplus
|
||||
//}
|
||||
#endif
|
||||
|
||||
#endif /* GNC_DRUID_PROVIDER_FILE_CB_H */
|
@ -1,196 +0,0 @@
|
||||
/********************************************************************\
|
||||
* gnc-druid-provider.c *
|
||||
* *
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include "gnc-druid-provider.h"
|
||||
#include "gnc-basic-gobject.h"
|
||||
|
||||
static void gnc_druid_provider_class_init (GNCDruidProviderClass *class);
|
||||
static void gnc_druid_provider_finalize (GObject *obj);
|
||||
static GNCDruidPage* null_page(GNCDruidProvider* provider);
|
||||
static GNCDruidPage* invalid_page(GNCDruidProvider* provider);
|
||||
|
||||
static GObjectClass *parent_class;
|
||||
static GHashTable *typeTable = NULL;
|
||||
|
||||
GNC_BASIC_GOBJECT_TYPE(GNCDruidProvider, GNCDruidProviderClass,
|
||||
G_TYPE_OBJECT, gnc_druid_provider_class_init, NULL,
|
||||
gnc_druid_provider_get_type)
|
||||
|
||||
static void
|
||||
gnc_druid_provider_class_init (GNCDruidProviderClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gnc_druid_provider_finalize;
|
||||
|
||||
/* override methods */
|
||||
klass->first_page = invalid_page;
|
||||
klass->last_page = invalid_page;
|
||||
klass->next_page = null_page;
|
||||
klass->prev_page = null_page;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_druid_provider_finalize (GObject *obj)
|
||||
{
|
||||
GNCDruidProvider *provider = (GNCDruidProvider *)obj;
|
||||
|
||||
/* Destroy the page list */
|
||||
g_list_free(provider->pages);
|
||||
|
||||
/* Destroy the provider descriptor */
|
||||
g_object_unref(G_OBJECT(provider->desc));
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize(obj);
|
||||
}
|
||||
|
||||
static GNCDruidPage*
|
||||
invalid_page(GNCDruidProvider* provider)
|
||||
{
|
||||
g_warning("Provider without a valid first/last page method");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static GNCDruidPage*
|
||||
null_page(GNCDruidProvider* provider)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static GHashTable*
|
||||
find_or_make_table(GHashTable* table, const gchar *str)
|
||||
{
|
||||
GHashTable *ret;
|
||||
|
||||
g_return_val_if_fail(table, NULL);
|
||||
g_return_val_if_fail(str, NULL);
|
||||
|
||||
ret = g_hash_table_lookup(table, str);
|
||||
if (!ret)
|
||||
{
|
||||
ret = g_hash_table_new(g_str_hash, g_str_equal);
|
||||
g_hash_table_insert(table, (gpointer)str, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_druid_provider_register(const gchar* ui_type, const gchar* name,
|
||||
GNCDruidProviderNew new_provider)
|
||||
{
|
||||
GHashTable *table;
|
||||
|
||||
g_return_if_fail(ui_type);
|
||||
g_return_if_fail(name);
|
||||
g_return_if_fail(new_provider);
|
||||
|
||||
if (!typeTable)
|
||||
typeTable = g_hash_table_new(g_str_hash, g_str_equal);
|
||||
|
||||
table = find_or_make_table(typeTable, ui_type);
|
||||
g_return_if_fail(table);
|
||||
|
||||
g_hash_table_insert(table, (gpointer)name, new_provider);
|
||||
}
|
||||
|
||||
GNCDruidProvider* gnc_druid_provider_new(GNCDruid* druid_ctx,
|
||||
GNCDruidProviderDesc* desc)
|
||||
{
|
||||
GHashTable *table;
|
||||
GNCDruidProviderNew new_provider;
|
||||
GNCDruidProvider *provider;
|
||||
|
||||
g_return_val_if_fail(desc, NULL);
|
||||
g_return_val_if_fail(IS_GNC_DRUID_PROVIDER_DESC(desc), NULL);
|
||||
g_return_val_if_fail(druid_ctx, NULL);
|
||||
g_return_val_if_fail(IS_GNC_DRUID(druid_ctx), NULL);
|
||||
g_return_val_if_fail(typeTable, NULL);
|
||||
g_return_val_if_fail(desc->name, NULL);
|
||||
g_return_val_if_fail(!desc->provider, NULL);
|
||||
|
||||
/* Lookup the UI Type provider table */
|
||||
table = g_hash_table_lookup(typeTable, druid_ctx->ui_type);
|
||||
g_return_val_if_fail(table, NULL);
|
||||
|
||||
/* Now look up the actual provider creator for this provider type */
|
||||
new_provider = g_hash_table_lookup(table, desc->name);
|
||||
g_return_val_if_fail(new_provider, NULL);
|
||||
|
||||
/* Create the new provider, then set the local parameters */
|
||||
provider = new_provider(druid_ctx, desc);
|
||||
if (provider)
|
||||
{
|
||||
provider->druid = druid_ctx;
|
||||
provider->desc = desc;
|
||||
desc->provider = provider;
|
||||
}
|
||||
|
||||
return provider;
|
||||
}
|
||||
|
||||
/* methods */
|
||||
|
||||
GNCDruidPage*
|
||||
gnc_druid_provider_first_page(GNCDruidProvider* provider)
|
||||
{
|
||||
g_return_val_if_fail(provider, NULL);
|
||||
g_return_val_if_fail(IS_GNC_DRUID_PROVIDER(provider), NULL);
|
||||
|
||||
return ((GNC_DRUID_PROVIDER_GET_CLASS(provider))->first_page)(provider);
|
||||
}
|
||||
|
||||
GNCDruidPage*
|
||||
gnc_druid_provider_last_page(GNCDruidProvider* provider)
|
||||
{
|
||||
g_return_val_if_fail(provider, NULL);
|
||||
g_return_val_if_fail(IS_GNC_DRUID_PROVIDER(provider), NULL);
|
||||
|
||||
return ((GNC_DRUID_PROVIDER_GET_CLASS(provider))->last_page)(provider);
|
||||
}
|
||||
|
||||
GNCDruidPage*
|
||||
gnc_druid_provider_next_page(GNCDruidProvider* provider)
|
||||
{
|
||||
g_return_val_if_fail(provider, NULL);
|
||||
g_return_val_if_fail(IS_GNC_DRUID_PROVIDER(provider), NULL);
|
||||
|
||||
return ((GNC_DRUID_PROVIDER_GET_CLASS(provider))->next_page)(provider);
|
||||
}
|
||||
|
||||
GNCDruidPage*
|
||||
gnc_druid_provider_prev_page(GNCDruidProvider* provider)
|
||||
{
|
||||
g_return_val_if_fail(provider, NULL);
|
||||
g_return_val_if_fail(IS_GNC_DRUID_PROVIDER(provider), NULL);
|
||||
|
||||
return ((GNC_DRUID_PROVIDER_GET_CLASS(provider))->prev_page)(provider);
|
||||
}
|
||||
|
||||
GList*
|
||||
gnc_druid_provider_get_pages(GNCDruidProvider* provider)
|
||||
{
|
||||
g_return_val_if_fail(provider, NULL);
|
||||
g_return_val_if_fail(IS_GNC_DRUID_PROVIDER(provider), NULL);
|
||||
|
||||
return provider->pages;
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
/********************************************************************\
|
||||
* gnc-druid-provider.h *
|
||||
* *
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#ifndef GNC_DRUID_PROVIDER_H
|
||||
#define GNC_DRUID_PROVIDER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
//extern "C" {
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#define G_TYPE_GNC_DRUID_PROVIDER (gnc_druid_provider_get_type())
|
||||
#define GNC_DRUID_PROVIDER(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_GNC_DRUID_PROVIDER, GNCDruidProvider)
|
||||
#define GNC_DRUID_PROVIDER_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_GNC_DRUID_PROVIDER, GNCDruidProviderClass)
|
||||
#define IS_GNC_DRUID_PROVIDER(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_GNC_DRUID_PROVIDER)
|
||||
#define IS_GNC_DRUID_PROVIDER_CLASS(klass) G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_GNC_DRUID_PROVIDER)
|
||||
#define GNC_DRUID_PROVIDER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_GNC_DRUID_PROVIDER, GNCDruidProviderClass))
|
||||
|
||||
typedef struct _GNCDruidProvider GNCDruidProvider;
|
||||
typedef struct _GNCDruidProviderClass GNCDruidProviderClass;
|
||||
|
||||
#include "gnc-druid.h"
|
||||
#include "gnc-druid-provider-desc.h"
|
||||
|
||||
struct _GNCDruidProvider
|
||||
{
|
||||
GObject obj;
|
||||
|
||||
GNCDruid *druid; /* The druid this object belongs to,
|
||||
* inserted by this class. */
|
||||
GNCDruidProviderDesc *desc; /* The description for this provider.
|
||||
* inserted by this class,
|
||||
* destroyed at finalize() */
|
||||
GList *pages; /* list of ALL druid pages created by the
|
||||
* subclass. destroyed at finalize() */
|
||||
GNCDruidPage* page; /* The current page, used for reference */
|
||||
};
|
||||
|
||||
struct _GNCDruidProviderClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
/* virtual methods */
|
||||
|
||||
GNCDruidPage* (*first_page)(GNCDruidProvider*);
|
||||
GNCDruidPage* (*last_page)(GNCDruidProvider*);
|
||||
GNCDruidPage* (*next_page)(GNCDruidProvider*);
|
||||
GNCDruidPage* (*prev_page)(GNCDruidProvider*);
|
||||
};
|
||||
|
||||
GType gnc_druid_provider_get_type(void);
|
||||
GNCDruidProvider* gnc_druid_provider_new(GNCDruid* druid,
|
||||
GNCDruidProviderDesc* desc);
|
||||
|
||||
|
||||
typedef GNCDruidProvider* (*GNCDruidProviderNew)(GNCDruid*, GNCDruidProviderDesc*);
|
||||
void gnc_druid_provider_register(const gchar* ui_type, const gchar* name,
|
||||
GNCDruidProviderNew new_provider);
|
||||
|
||||
/* methods */
|
||||
|
||||
GNCDruidPage* gnc_druid_provider_first_page(GNCDruidProvider*);
|
||||
GNCDruidPage* gnc_druid_provider_last_page(GNCDruidProvider*);
|
||||
GNCDruidPage* gnc_druid_provider_next_page(GNCDruidProvider*);
|
||||
GNCDruidPage* gnc_druid_provider_prev_page(GNCDruidProvider*);
|
||||
|
||||
GList* gnc_druid_provider_get_pages(GNCDruidProvider*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
//}
|
||||
#endif
|
||||
|
||||
#endif /* GNC_DRUID_PROVIDER_H */
|
@ -1,339 +0,0 @@
|
||||
/********************************************************************\
|
||||
* gnc-druid.c *
|
||||
* *
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include "gnc-druid.h"
|
||||
|
||||
static void gnc_druid_class_init (GNCDruidClass *class);
|
||||
static void gnc_druid_finalize (GObject *obj);
|
||||
static void invalid_setpage(GNCDruid* druid, GNCDruidPage* page);
|
||||
|
||||
static GObjectClass *parent_class;
|
||||
static GNCDruidNew new_druid_fcn = NULL;
|
||||
|
||||
GType
|
||||
gnc_druid_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
if (type == 0)
|
||||
{
|
||||
GTypeInfo type_info =
|
||||
{
|
||||
sizeof (GNCDruidClass),
|
||||
NULL,
|
||||
NULL,
|
||||
(GClassInitFunc)gnc_druid_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof (GNCDruid),
|
||||
0,
|
||||
NULL,
|
||||
};
|
||||
|
||||
type = g_type_register_static (G_TYPE_OBJECT, "GNCDruid", &type_info, 0);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_druid_class_init (GNCDruidClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gnc_druid_finalize;
|
||||
|
||||
/* override methods */
|
||||
klass->set_page = invalid_setpage;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_druid_finalize (GObject *obj)
|
||||
{
|
||||
GNCDruid *druid = (GNCDruid *)obj;
|
||||
GList *node;
|
||||
|
||||
/* Cancel the backend context */
|
||||
if (druid->cancel)
|
||||
(druid->cancel)(druid->be_ctx);
|
||||
|
||||
/* Destroy list of providers */
|
||||
for (node = druid->providers; node; node = node->next)
|
||||
g_object_unref(G_OBJECT(node->data));
|
||||
g_list_free(druid->providers);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize(obj);
|
||||
}
|
||||
|
||||
static void invalid_setpage(GNCDruid* druid, GNCDruidPage* page)
|
||||
{
|
||||
g_warning("druid with invalid set-page");
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_druid_register_ui(const gchar* ui_type, GNCDruidNew new_druid)
|
||||
{
|
||||
g_return_if_fail(ui_type);
|
||||
g_return_if_fail(new_druid);
|
||||
g_return_if_fail(!new_druid_fcn);
|
||||
|
||||
new_druid_fcn = new_druid;
|
||||
}
|
||||
|
||||
/* methods */
|
||||
|
||||
void
|
||||
gnc_druid_set_page(GNCDruid* druid, GNCDruidPage* page)
|
||||
{
|
||||
g_return_if_fail(druid);
|
||||
g_return_if_fail(IS_GNC_DRUID(druid));
|
||||
|
||||
((GNC_DRUID_GET_CLASS(druid))->set_page)(druid, page);
|
||||
}
|
||||
|
||||
static GNCDruidProvider*
|
||||
gnc_druid_set_provider_node(GNCDruid* druid, GList *node)
|
||||
{
|
||||
druid->this_provider = node;
|
||||
druid->provider = (node ? node->data : NULL);
|
||||
return druid->provider;
|
||||
}
|
||||
|
||||
GNCDruidProvider*
|
||||
gnc_druid_next_provider(GNCDruid* druid)
|
||||
{
|
||||
GList *node;
|
||||
|
||||
g_return_val_if_fail(druid, NULL);
|
||||
g_return_val_if_fail(IS_GNC_DRUID(druid), NULL);
|
||||
|
||||
if (!druid->this_provider)
|
||||
{
|
||||
node = druid->providers;
|
||||
}
|
||||
else
|
||||
{
|
||||
node = druid->this_provider->next;
|
||||
}
|
||||
|
||||
return gnc_druid_set_provider_node(druid, node);
|
||||
}
|
||||
|
||||
GNCDruidProvider*
|
||||
gnc_druid_prev_provider(GNCDruid* druid)
|
||||
{
|
||||
GList *node;
|
||||
|
||||
g_return_val_if_fail(druid, NULL);
|
||||
g_return_val_if_fail(IS_GNC_DRUID(druid), NULL);
|
||||
|
||||
if (!druid->provider)
|
||||
{
|
||||
node = g_list_last(druid->providers);
|
||||
}
|
||||
else
|
||||
{
|
||||
node = druid->this_provider->prev;
|
||||
}
|
||||
|
||||
return gnc_druid_set_provider_node(druid, node);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gnc_druid_change_page(GNCDruid *druid,
|
||||
GNCDruidProvider* (*next_prov)(GNCDruid*),
|
||||
GNCDruidPage* (*first_page)(GNCDruidProvider*),
|
||||
GNCDruidPage* (*next_page)(GNCDruidProvider*),
|
||||
gboolean first)
|
||||
{
|
||||
GNCDruidProvider *prov;
|
||||
GNCDruidPage* page = NULL;
|
||||
|
||||
for (prov = druid->provider; !page; )
|
||||
{
|
||||
|
||||
/* How we behave depends on whether we have a provider...
|
||||
* if we do not have a provider, then get the next one and
|
||||
* try to get the first page. If we DO have a provider, then
|
||||
* ask for the next page. If neither gave us a page then we
|
||||
* should go to the next provider. Once we get a page or if
|
||||
* we hit the next of the provider list, we're done.
|
||||
*/
|
||||
|
||||
if (!prov || first)
|
||||
{
|
||||
|
||||
/* Nope, no provider */
|
||||
if (!prov || !first)
|
||||
prov = next_prov(druid);
|
||||
|
||||
if (!prov)
|
||||
break;
|
||||
|
||||
/* New provider -- get the first page */
|
||||
page = first_page(prov);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Yep, try to get the next page */
|
||||
page = next_page(prov);
|
||||
}
|
||||
|
||||
/* If we didn't get a page then we need to change providers. If
|
||||
* the callback didn't jump us elsewhere, then we should set prov
|
||||
* to NULL and go to the next provider. But if we jumped, then
|
||||
* we'll assume the jump set the pages properly and we'll just go
|
||||
* there. Note that this means we cannot "jump" into ourself, but
|
||||
* that's ok, because we could have jump returned our own page if
|
||||
* we wanted to do that.
|
||||
*/
|
||||
if (!page)
|
||||
{
|
||||
if (druid->jump_count)
|
||||
return;
|
||||
prov = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (page)
|
||||
gnc_druid_set_page(druid, page);
|
||||
|
||||
g_return_if_fail(page);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_druid_next_page_internal(GNCDruid* druid, gboolean first)
|
||||
{
|
||||
gnc_druid_change_page(druid, gnc_druid_next_provider,
|
||||
gnc_druid_provider_first_page, gnc_druid_provider_next_page,
|
||||
first);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_druid_next_page(GNCDruid* druid)
|
||||
{
|
||||
g_return_if_fail(druid);
|
||||
g_return_if_fail(IS_GNC_DRUID(druid));
|
||||
|
||||
gnc_druid_next_page_internal(druid, FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_druid_prev_page(GNCDruid* druid)
|
||||
{
|
||||
g_return_if_fail(druid);
|
||||
g_return_if_fail(IS_GNC_DRUID(druid));
|
||||
|
||||
gnc_druid_change_page(druid, gnc_druid_prev_provider,
|
||||
gnc_druid_provider_last_page, gnc_druid_provider_prev_page,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_druid_jump_to_provider(GNCDruid* druid, GNCDruidProvider* prov)
|
||||
{
|
||||
GList *node;
|
||||
|
||||
g_return_if_fail(druid);
|
||||
g_return_if_fail(IS_GNC_DRUID(druid));
|
||||
g_return_if_fail(prov);
|
||||
g_return_if_fail(IS_GNC_DRUID_PROVIDER(prov));
|
||||
|
||||
node = g_list_find(druid->providers, prov);
|
||||
g_return_if_fail(node);
|
||||
|
||||
druid->jump_count++;
|
||||
gnc_druid_set_provider_node(druid, node);
|
||||
gnc_druid_next_page_internal(druid, TRUE);
|
||||
druid->jump_count--;
|
||||
}
|
||||
|
||||
/* Other functions */
|
||||
|
||||
/**
|
||||
* gnc_druid_new -- create a druid based on the list of providers. Hold
|
||||
* onto the backend context and the function to call if
|
||||
* the druid is cancelled.
|
||||
*
|
||||
* This will assume the "registered ui", or internally perform some
|
||||
* magic to figure out which "UI" to use..
|
||||
*
|
||||
* The provider list (and all the providerdesc objects) are owned by
|
||||
* the druid and will be freed by the druid.
|
||||
*/
|
||||
GNCDruid* gnc_druid_new(const gchar* title, GList *providers, gpointer backend_ctx,
|
||||
gboolean (*finish)(gpointer be_ctx),
|
||||
void (*cancel)(gpointer be_ctx))
|
||||
{
|
||||
GNCDruid *druid;
|
||||
GList *prov_list = NULL;
|
||||
GList *node;
|
||||
GNCDruidProvider *prov;
|
||||
GNCDruidClass *gdc;
|
||||
|
||||
g_return_val_if_fail(title, NULL);
|
||||
g_return_val_if_fail(providers, NULL);
|
||||
g_return_val_if_fail(new_druid_fcn, NULL);
|
||||
|
||||
/* Build the druid */
|
||||
druid = new_druid_fcn(title);
|
||||
g_return_val_if_fail(druid, NULL);
|
||||
g_return_val_if_fail(druid->ui_type, NULL);
|
||||
|
||||
/* Fill in local data */
|
||||
druid->be_ctx = backend_ctx;
|
||||
druid->finish = finish;
|
||||
druid->cancel = cancel;
|
||||
|
||||
gdc = GNC_DRUID_GET_CLASS(druid);
|
||||
g_return_val_if_fail(gdc->append_provider, NULL);
|
||||
|
||||
/* Now build the set of providers */
|
||||
for (node = providers; node; node = node->next)
|
||||
{
|
||||
GNCDruidProviderDesc *prov_desc = node->data;
|
||||
|
||||
/* create the provider */
|
||||
g_assert(prov_desc);
|
||||
prov = gnc_druid_provider_new(druid, prov_desc);
|
||||
g_assert(prov);
|
||||
|
||||
/* add the provider to the druid */
|
||||
gdc->append_provider(druid, prov);
|
||||
prov_list = g_list_prepend(prov_list, prov);
|
||||
}
|
||||
druid->providers = g_list_reverse(prov_list);
|
||||
|
||||
/* Free the list (the provider descriptions are in the providers) */
|
||||
g_list_free(providers);
|
||||
|
||||
/* Set the first page of the druid */
|
||||
gnc_druid_next_page(druid);
|
||||
|
||||
/* And return the new druid. */
|
||||
return druid;
|
||||
}
|
@ -1,113 +0,0 @@
|
||||
/********************************************************************\
|
||||
* gnc-druid.h *
|
||||
* *
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#ifndef GNC_DRUID_H
|
||||
#define GNC_DRUID_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
//extern "C" {
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#define G_TYPE_GNC_DRUID (gnc_druid_get_type())
|
||||
#define GNC_DRUID(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_GNC_DRUID, GNCDruid)
|
||||
#define GNC_DRUID_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_GNC_DRUID, GNCDruidClass)
|
||||
#define IS_GNC_DRUID(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_GNC_DRUID)
|
||||
#define IS_GNC_DRUID_CLASS(klass) G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_GNC_DRUID)
|
||||
#define GNC_DRUID_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), G_TYPE_GNC_DRUID, GNCDruidClass))
|
||||
|
||||
typedef struct _GNCDruid GNCDruid;
|
||||
typedef struct _GNCDruidClass GNCDruidClass;
|
||||
typedef void GNCDruidPage; /* completely opaque.Do we need to know anything? */
|
||||
|
||||
#include "gnc-druid-cb.h"
|
||||
#include "gnc-druid-provider-desc.h"
|
||||
#include "gnc-druid-provider.h"
|
||||
|
||||
struct _GNCDruid
|
||||
{
|
||||
GObject obj;
|
||||
|
||||
/* PROVIDED BY TOOLKIT IMPLEMENTATION... */
|
||||
const gchar *ui_type;
|
||||
|
||||
/* PROVIDED HEREIN */
|
||||
GList *providers; /* list of GNCProvider*; list is owned herein */
|
||||
GList *this_provider; /* a pointer to the current provider */
|
||||
GNCDruidProvider *provider; /* current provider */
|
||||
|
||||
/* Backend information */
|
||||
gpointer be_ctx; /* backend context pointer */
|
||||
gboolean (*finish)(gpointer); /* backend 'finish process' pointer */
|
||||
void (*cancel)(gpointer); /* backend 'cancel process' pointer */
|
||||
|
||||
gint jump_count;
|
||||
};
|
||||
|
||||
struct _GNCDruidClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
/* virtual methods */
|
||||
void (*set_page)(GNCDruid*, GNCDruidPage*);
|
||||
void (*append_provider)(GNCDruid*, GNCDruidProvider*);
|
||||
};
|
||||
|
||||
GType gnc_druid_get_type(void);
|
||||
|
||||
typedef GNCDruid* (*GNCDruidNew)(const char* title);
|
||||
void gnc_druid_register_ui(const gchar* ui_type, GNCDruidNew new_druid);
|
||||
|
||||
/* methods */
|
||||
|
||||
void gnc_druid_set_page(GNCDruid*, GNCDruidPage*);
|
||||
GNCDruidProvider* gnc_druid_next_provider(GNCDruid*);
|
||||
GNCDruidProvider* gnc_druid_prev_provider(GNCDruid*);
|
||||
|
||||
void gnc_druid_next_page(GNCDruid*);
|
||||
void gnc_druid_prev_page(GNCDruid*);
|
||||
|
||||
/* Reset the druid page by jumping to the provider. */
|
||||
void gnc_druid_jump_to_provider(GNCDruid*, GNCDruidProvider*);
|
||||
|
||||
/* Other functions */
|
||||
|
||||
/**
|
||||
* gnc_druid_new -- create a druid based on the list of providers
|
||||
* descriptors. Hold onto the backend context and
|
||||
* the function to call when druid is finished.
|
||||
*
|
||||
* This will assume the "registered ui", or internally perform some
|
||||
* magic to figure out which "UI" to use..
|
||||
*
|
||||
* The provider list (and all the providerdesc objects) are owned by
|
||||
* the druid and will be freed by the druid.
|
||||
*/
|
||||
GNCDruid* gnc_druid_new(const gchar* title,
|
||||
GList *providers, gpointer backend_ctx,
|
||||
gboolean (*finish)(gpointer be_ctx),
|
||||
void (*cancel)(gpointer be_ctx));
|
||||
|
||||
#ifdef __cplusplus
|
||||
//}
|
||||
#endif
|
||||
|
||||
#endif /* GNC_DRUID_H */
|
@ -62,7 +62,6 @@
|
||||
#define GNC_MOD_HTML "gnc.html"
|
||||
#define GNC_MOD_PREFS "gnc.pref"
|
||||
#define GNC_MOD_IMPORT "gnc.import"
|
||||
#define GNC_MOD_DRUID "gnc.druids"
|
||||
#define GNC_MOD_ASSISTANT "gnc.assistant"
|
||||
#define GNC_MOD_TEST "gnc.tests"
|
||||
#define GNC_MOD_BUDGET "gnc.budget"
|
||||
|
@ -60,10 +60,6 @@ libgncmod_gnome_utils_la_SOURCES = \
|
||||
gnc-dense-cal-model.c \
|
||||
gnc-dense-cal-store.c \
|
||||
gnc-dialog.c \
|
||||
gnc-druid-gnome.c \
|
||||
gnc-druid-provider-edge-gnome.c \
|
||||
gnc-druid-provider-file-gnome.c \
|
||||
gnc-druid-provider-multifile-gnome.c \
|
||||
gnc-embedded-window.c \
|
||||
gnc-file.c \
|
||||
gnc-frequency.c \
|
||||
@ -138,7 +134,6 @@ gncinclude_HEADERS = \
|
||||
gnc-dense-cal.h \
|
||||
gnc-dense-cal-model.h \
|
||||
gnc-dense-cal-store.h \
|
||||
gnc-druid-gnome-ui.h \
|
||||
gnc-embedded-window.h \
|
||||
gnc-file.h \
|
||||
gnc-frequency.h \
|
||||
@ -183,10 +178,6 @@ gncinclude_HEADERS = \
|
||||
noinst_HEADERS = \
|
||||
dialog-tax-table.h \
|
||||
gnc-autosave.h \
|
||||
gnc-druid-gnome.h \
|
||||
gnc-druid-provider-edge-gnome.h \
|
||||
gnc-druid-provider-file-gnome.h \
|
||||
gnc-druid-provider-multifile-gnome.h \
|
||||
gnc-gobject-utils.h \
|
||||
gnc-gtk-utils.h \
|
||||
search-param.h
|
||||
|
@ -1,7 +0,0 @@
|
||||
|
||||
#ifndef GNC_DRUID_GNOME_UI_H
|
||||
#define GNC_DRUID_GNOME_UI_H
|
||||
|
||||
#define GNC_DRUID_GNOME_UI "gnome"
|
||||
|
||||
#endif /* GNC_DRUID_GNOME_UI_H */
|
@ -1,187 +0,0 @@
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include "gnc-druid-gnome.h"
|
||||
|
||||
static void gnc_druid_gnome_class_init (GNCDruidGnomeClass *class);
|
||||
static void gnc_druid_gnome_finalize (GObject *obj);
|
||||
|
||||
static void gnc_druid_gnome_set_page(GNCDruid* druid, GNCDruidPage* page);
|
||||
static void gnc_druid_gnome_append_provider(GNCDruid*, GNCDruidProvider*);
|
||||
|
||||
static gboolean gnc_druid_gnome_next_cb(GnomeDruidPage* page, GtkWidget *arg1,
|
||||
gpointer user_data);
|
||||
static gboolean gnc_druid_gnome_prev_cb(GnomeDruidPage* page, GtkWidget *arg1,
|
||||
gpointer user_data);
|
||||
static gboolean gnc_druid_gnome_cancel2_cb(GnomeDruidPage* page, GtkWidget *arg1,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
static GNCDruidClass *parent_class;
|
||||
|
||||
GType
|
||||
gnc_druid_gnome_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
if (type == 0)
|
||||
{
|
||||
GTypeInfo type_info =
|
||||
{
|
||||
sizeof (GNCDruidGnomeClass),
|
||||
NULL,
|
||||
NULL,
|
||||
(GClassInitFunc)gnc_druid_gnome_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof (GNCDruidGnome),
|
||||
0,
|
||||
NULL,
|
||||
};
|
||||
|
||||
type = g_type_register_static (G_TYPE_GNC_DRUID, "GNCDruidGnome", &type_info, 0);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_druid_gnome_class_init (GNCDruidGnomeClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
GNCDruidClass *gdc_class = (GNCDruidClass*)klass;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gnc_druid_gnome_finalize;
|
||||
|
||||
/* override methods */
|
||||
gdc_class->set_page = gnc_druid_gnome_set_page;
|
||||
gdc_class->append_provider = gnc_druid_gnome_append_provider;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_druid_gnome_finalize (GObject *obj)
|
||||
{
|
||||
GNCDruidGnome *druid = (GNCDruidGnome *)obj;
|
||||
|
||||
gtk_widget_destroy(druid->window);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_druid_gnome_set_page(GNCDruid* druid_p, GNCDruidPage* page)
|
||||
{
|
||||
GNCDruidGnome *druid;
|
||||
|
||||
g_return_if_fail(druid_p);
|
||||
g_return_if_fail(IS_GNC_DRUID_GNOME(druid_p));
|
||||
|
||||
druid = GNC_DRUID_GNOME(druid_p);
|
||||
gnome_druid_set_page(druid->druid, GNOME_DRUID_PAGE(page));
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_druid_gnome_append_provider(GNCDruid* druid_p, GNCDruidProvider* provider)
|
||||
{
|
||||
GNCDruidGnome *druid;
|
||||
GList *pages, *node;
|
||||
GnomeDruidPage *page;
|
||||
|
||||
g_return_if_fail(druid_p);
|
||||
g_return_if_fail(IS_GNC_DRUID_GNOME(druid_p));
|
||||
g_return_if_fail(provider);
|
||||
g_return_if_fail(IS_GNC_DRUID_PROVIDER(provider));
|
||||
|
||||
druid = GNC_DRUID_GNOME(druid_p);
|
||||
pages = gnc_druid_provider_get_pages(provider);
|
||||
for (node = pages; node; node = node->next)
|
||||
{
|
||||
page = GNOME_DRUID_PAGE(node->data);
|
||||
gnome_druid_append_page(druid->druid, page);
|
||||
g_signal_connect(G_OBJECT(page), "next",
|
||||
(GCallback)gnc_druid_gnome_next_cb, druid);
|
||||
g_signal_connect(G_OBJECT(page), "back",
|
||||
(GCallback)gnc_druid_gnome_prev_cb, druid);
|
||||
g_signal_connect(G_OBJECT(page), "cancel",
|
||||
(GCallback)gnc_druid_gnome_cancel2_cb, druid);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnc_druid_gnome_next_cb(GnomeDruidPage* page, GtkWidget *arg1, gpointer user_data)
|
||||
{
|
||||
GNCDruid *druid;
|
||||
|
||||
g_return_val_if_fail(IS_GNC_DRUID_GNOME(user_data), FALSE);
|
||||
druid = GNC_DRUID(user_data);
|
||||
|
||||
/* Move to the next druid page */
|
||||
gnc_druid_next_page(druid);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnc_druid_gnome_prev_cb(GnomeDruidPage* page, GtkWidget *arg1, gpointer user_data)
|
||||
{
|
||||
GNCDruid *druid;
|
||||
|
||||
g_return_val_if_fail(IS_GNC_DRUID_GNOME(user_data), FALSE);
|
||||
druid = GNC_DRUID(user_data);
|
||||
|
||||
/* move to the previous druid page */
|
||||
gnc_druid_prev_page(druid);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnc_druid_gnome_cancel2_cb(GnomeDruidPage* page, GtkWidget *arg1,
|
||||
gpointer user_data)
|
||||
{
|
||||
GObject *obj = (GObject*)user_data;
|
||||
|
||||
g_object_unref(obj);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_druid_gnome_cancel_cb(GnomeDruid* druid, gpointer user_data)
|
||||
{
|
||||
GObject *obj = (GObject*)user_data;
|
||||
|
||||
g_object_unref(obj);
|
||||
}
|
||||
|
||||
static GNCDruid*
|
||||
gnc_druid_gnome_build(const char* title)
|
||||
{
|
||||
GNCDruidGnome *druid;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *window = NULL;
|
||||
|
||||
/* Build myself */
|
||||
druid = GNC_DRUID_GNOME(g_object_new(G_TYPE_GNC_DRUID_GNOME, NULL));
|
||||
druid->parent.ui_type = GNC_DRUID_GNOME_UI;
|
||||
|
||||
/* Build the gnome druid */
|
||||
widget = gnome_druid_new_with_window(title, NULL, TRUE, &window);
|
||||
g_return_val_if_fail(widget, NULL);
|
||||
druid->druid = GNOME_DRUID(widget);
|
||||
druid->window = window;
|
||||
|
||||
g_signal_connect(G_OBJECT(widget), "cancel",
|
||||
(GCallback)gnc_druid_gnome_cancel_cb, druid);
|
||||
gtk_widget_show_all(widget);
|
||||
|
||||
return GNC_DRUID(druid);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_druid_gnome_register(void)
|
||||
{
|
||||
gnc_druid_register_ui(GNC_DRUID_GNOME_UI, gnc_druid_gnome_build);
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
|
||||
|
||||
#ifndef GNC_DRUID_GNOME_H
|
||||
#define GNC_DRUID_GNOME_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
//extern "C" {
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <libgnomeui/libgnomeui.h>
|
||||
#include "gnc-druid.h"
|
||||
#include "gnc-druid-gnome-ui.h"
|
||||
|
||||
#define G_TYPE_GNC_DRUID_GNOME (gnc_druid_gnome_get_type())
|
||||
#define GNC_DRUID_GNOME(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_GNC_DRUID_GNOME, GNCDruidGnome)
|
||||
#define GNC_DRUID_GNOME_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_GNC_DRUID_GNOME, GNCDruidGnomeClass)
|
||||
#define IS_GNC_DRUID_GNOME(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_GNC_DRUID_GNOME)
|
||||
#define IS_GNC_DRUID_GNOME_CLASS(klass) G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_GNC_DRUID_GNOME)
|
||||
#define GNC_DRUID_GNOME_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), G_TYPE_GNC_DRUID_GNOME, GNCDruidGnomeClass))
|
||||
|
||||
typedef struct _GNCDruidGnome GNCDruidGnome;
|
||||
typedef struct _GNCDruidGnomeClass GNCDruidGnomeClass;
|
||||
|
||||
struct _GNCDruidGnome
|
||||
{
|
||||
GNCDruid parent;
|
||||
|
||||
GnomeDruid* druid;
|
||||
GtkWidget* window;
|
||||
};
|
||||
|
||||
struct _GNCDruidGnomeClass
|
||||
{
|
||||
GNCDruidClass parent_class;
|
||||
};
|
||||
|
||||
GType gnc_druid_gnome_get_type(void);
|
||||
void gnc_druid_gnome_register(void);
|
||||
|
||||
/* methods */
|
||||
|
||||
#ifdef __cplusplus
|
||||
//}
|
||||
#endif
|
||||
|
||||
#endif /* GNC_DRUID_GNOME_H */
|
@ -1,129 +0,0 @@
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include "gnc-druid-gnome-ui.h"
|
||||
#include "gnc-druid-provider-edge-gnome.h"
|
||||
#include "gnc-druid-provider-desc-edge.h"
|
||||
|
||||
#include "gnc-basic-gobject.h"
|
||||
|
||||
static void gnc_druid_provider_edge_gnome_class_init (GNCDruidProviderEdgeGnomeClass *class);
|
||||
static void gnc_druid_provider_edge_gnome_finalize (GObject *obj);
|
||||
|
||||
static GNCDruidPage* gnc_dp_edge_gnome_first_page(GNCDruidProvider*);
|
||||
static GNCDruidPage* gnc_dp_edge_gnome_last_page(GNCDruidProvider*);
|
||||
|
||||
static GNCDruidProviderClass *parent_class;
|
||||
|
||||
GNC_BASIC_GOBJECT_TYPE(GNCDruidProviderEdgeGnome, GNCDruidProviderEdgeGnomeClass,
|
||||
G_TYPE_GNC_DRUID_PROVIDER,
|
||||
gnc_druid_provider_edge_gnome_class_init, NULL,
|
||||
gnc_druid_provider_edge_gnome_get_type)
|
||||
|
||||
static void
|
||||
gnc_druid_provider_edge_gnome_class_init (GNCDruidProviderEdgeGnomeClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
GNCDruidProviderClass *gdp_class = (GNCDruidProviderClass*)klass;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gnc_druid_provider_edge_gnome_finalize;
|
||||
|
||||
/* override methods */
|
||||
gdp_class->first_page = gnc_dp_edge_gnome_first_page;
|
||||
gdp_class->last_page = gnc_dp_edge_gnome_last_page;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_druid_provider_edge_gnome_finalize (GObject *obj)
|
||||
{
|
||||
//GNCDruidProviderEdgeGnome *provider = (GNCDruidProviderEdgeGnome *)obj;
|
||||
|
||||
/* XXX: we don't need to do anything here. The page will be destroyed
|
||||
* from the druid, and the list is destroyed by the provider superclass.
|
||||
*/
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize(obj);
|
||||
}
|
||||
|
||||
static GNCDruidPage*
|
||||
gnc_dp_edge_gnome_first_page(GNCDruidProvider* prov)
|
||||
{
|
||||
return prov->pages->data;
|
||||
}
|
||||
|
||||
static GNCDruidPage*
|
||||
gnc_dp_edge_gnome_last_page(GNCDruidProvider* prov)
|
||||
{
|
||||
return prov->pages->data;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_dp_edge_gnome_finish_cb(GnomeDruidPage* page, GtkWidget* arg1,
|
||||
gpointer user_data)
|
||||
{
|
||||
GNCDruidProvider *prov;
|
||||
|
||||
g_return_if_fail(page);
|
||||
g_return_if_fail(user_data);
|
||||
g_return_if_fail(IS_GNC_DRUID_PROVIDER_EDGE_GNOME(user_data));
|
||||
|
||||
prov = GNC_DRUID_PROVIDER(user_data);
|
||||
if (prov->druid->finish)
|
||||
prov->druid->finish(prov->druid->be_ctx);
|
||||
|
||||
g_object_unref(G_OBJECT(prov->druid));
|
||||
}
|
||||
|
||||
static GNCDruidProvider*
|
||||
gnc_druid_pe_gnome_build(GNCDruid* druid, GNCDruidProviderDesc* desc)
|
||||
{
|
||||
GNCDruidProvider *prov_base;
|
||||
GNCDruidProviderEdgeGnome *prov;
|
||||
GNCDruidProviderDescEdge *desc_e;
|
||||
GnomeDruidPageEdge *page;
|
||||
|
||||
/* verify that this is the correct provider descriptor */
|
||||
g_return_val_if_fail(IS_GNC_DRUID_PROVIDER_DESC_EDGE(desc), NULL);
|
||||
desc_e = GNC_DRUID_PROVIDER_DESC_EDGE(desc);
|
||||
|
||||
/* Build the provider */
|
||||
prov = GNC_DRUID_PROVIDER_EDGE_GNOME(g_object_new(G_TYPE_GNC_DRUID_PROVIDER_EDGE_GNOME, NULL));
|
||||
g_assert(prov);
|
||||
prov_base = GNC_DRUID_PROVIDER(prov);
|
||||
|
||||
/* Build the Druid Page */
|
||||
page = GNOME_DRUID_PAGE_EDGE(gnome_druid_page_edge_new(desc_e->first_or_last ==
|
||||
GNC_DPE_FIRST ?
|
||||
GNOME_EDGE_START :
|
||||
GNOME_EDGE_FINISH));
|
||||
/* Remember this page for later */
|
||||
g_assert(page);
|
||||
prov->page = page;
|
||||
prov_base->pages = g_list_prepend(NULL, page);
|
||||
|
||||
/* Set the page properties */
|
||||
if (desc->title)
|
||||
gnome_druid_page_edge_set_title(page, desc->title);
|
||||
if (desc_e->text)
|
||||
gnome_druid_page_edge_set_text(page, desc_e->text);
|
||||
|
||||
/* Show the page */
|
||||
gtk_widget_show_all(GTK_WIDGET(page));
|
||||
|
||||
if (desc_e->first_or_last == GNC_DPE_LAST)
|
||||
g_signal_connect(G_OBJECT(page), "finish",
|
||||
(GCallback)gnc_dp_edge_gnome_finish_cb, prov);
|
||||
|
||||
/* Return the provider instance */
|
||||
return prov_base;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_druid_provider_edge_gnome_register(void)
|
||||
{
|
||||
gnc_druid_provider_register(GNC_DRUID_GNOME_UI, GNC_DRUID_PROVIDER_TYPE_EDGE,
|
||||
gnc_druid_pe_gnome_build);
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
|
||||
|
||||
#ifndef GNC_DRUID_PROVIDER_EDGE_GNOME_H
|
||||
#define GNC_DRUID_PROVIDER_EDGE_GNOME_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
//extern "C" {
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <libgnomeui/libgnomeui.h>
|
||||
#include "gnc-druid.h"
|
||||
|
||||
#define G_TYPE_GNC_DRUID_PROVIDER_EDGE_GNOME (gnc_druid_provider_edge_gnome_get_type())
|
||||
#define GNC_DRUID_PROVIDER_EDGE_GNOME(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_GNC_DRUID_PROVIDER_EDGE_GNOME, GNCDruidProviderEdgeGnome)
|
||||
#define GNC_DRUID_PROVIDER_EDGE_GNOME_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_GNC_DRUID_PROVIDER_EDGE_GNOME, GNCDruidProviderEdgeGnomeClass)
|
||||
#define IS_GNC_DRUID_PROVIDER_EDGE_GNOME(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_GNC_DRUID_PROVIDER_EDGE_GNOME)
|
||||
#define IS_GNC_DRUID_PROVIDER_EDGE_GNOME_CLASS(klass) G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_GNC_DRUID_PROVIDER_EDGE_GNOME)
|
||||
#define GNC_DRUID_PROVIDER_EDGE_GNOME_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), G_TYPE_GNC_DRUID_PROVIDER_EDGE_GNOME, GNCDruidProviderEdgeGnomeClass))
|
||||
|
||||
typedef struct _GNCDruidProviderEdgeGnome GNCDruidProviderEdgeGnome;
|
||||
typedef struct _GNCDruidProviderEdgeGnomeClass GNCDruidProviderEdgeGnomeClass;
|
||||
|
||||
struct _GNCDruidProviderEdgeGnome
|
||||
{
|
||||
GNCDruidProvider parent;
|
||||
|
||||
GnomeDruidPageEdge* page;
|
||||
};
|
||||
|
||||
struct _GNCDruidProviderEdgeGnomeClass
|
||||
{
|
||||
GNCDruidProviderClass parent_class;
|
||||
};
|
||||
|
||||
GType gnc_druid_provider_edge_gnome_get_type(void);
|
||||
void gnc_druid_provider_edge_gnome_register(void);
|
||||
|
||||
/* methods */
|
||||
|
||||
#ifdef __cplusplus
|
||||
//}
|
||||
#endif
|
||||
|
||||
#endif /* GNC_DRUID_PROVIDER_EDGE_GNOME_H */
|
@ -1,294 +0,0 @@
|
||||
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gnome.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "gnc-druid-gnome-ui.h"
|
||||
#include "gnc-druid-provider-file-gnome.h"
|
||||
#include "gnc-druid-provider-desc-file.h"
|
||||
|
||||
#include "gnc-basic-gobject.h"
|
||||
|
||||
#include "gnc-ui.h"
|
||||
#include "gnc-gui-query.h"
|
||||
|
||||
static void gnc_druid_provider_file_gnome_class_init (GNCDruidProviderFileGnomeClass *class);
|
||||
static void gnc_druid_provider_file_gnome_finalize (GObject *obj);
|
||||
|
||||
static GNCDruidPage* gnc_dp_file_gnome_first_page(GNCDruidProvider*);
|
||||
static GNCDruidPage* gnc_dp_file_gnome_last_page(GNCDruidProvider*);
|
||||
static GNCDruidPage* gnc_dp_file_gnome_next_page(GNCDruidProvider*);
|
||||
static GNCDruidPage* gnc_dp_file_gnome_prev_page(GNCDruidProvider*);
|
||||
|
||||
static GNCDruidProviderClass *parent_class;
|
||||
|
||||
GNC_BASIC_GOBJECT_TYPE(GNCDruidProviderFileGnome, GNCDruidProviderFileGnomeClass,
|
||||
G_TYPE_GNC_DRUID_PROVIDER,
|
||||
gnc_druid_provider_file_gnome_class_init, NULL,
|
||||
gnc_druid_provider_file_gnome_get_type)
|
||||
|
||||
static void
|
||||
gnc_druid_provider_file_gnome_class_init (GNCDruidProviderFileGnomeClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
GNCDruidProviderClass *gdp_class = (GNCDruidProviderClass*)klass;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gnc_druid_provider_file_gnome_finalize;
|
||||
|
||||
/* override methods */
|
||||
gdp_class->first_page = gnc_dp_file_gnome_first_page;
|
||||
gdp_class->last_page = gnc_dp_file_gnome_last_page;
|
||||
gdp_class->next_page = gnc_dp_file_gnome_next_page;
|
||||
gdp_class->prev_page = gnc_dp_file_gnome_prev_page;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_dpfg_end_glob(GNCDruidProviderFileGnome *prov)
|
||||
{
|
||||
if (prov->globbed)
|
||||
{
|
||||
#ifdef HAVE_GLOB_H
|
||||
globfree(&prov->glob);
|
||||
#endif
|
||||
prov->globbed = FALSE;
|
||||
prov->count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_druid_provider_file_gnome_finalize (GObject *obj)
|
||||
{
|
||||
GNCDruidProviderFileGnome *prov_f = (GNCDruidProviderFileGnome *)obj;
|
||||
|
||||
gnc_dpfg_end_glob(prov_f);
|
||||
g_object_unref(prov_f->cb);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize(obj);
|
||||
}
|
||||
|
||||
/* If we've got a file, remove it from the list.. */
|
||||
static void
|
||||
gnc_dpfg_del_file(GNCDruidProvider* prov)
|
||||
{
|
||||
GNCDruidProviderFileGnome *prov_f = GNC_DRUID_PROVIDER_FILE_GNOME(prov);
|
||||
GNCDruidProviderDescFile *desc_f = GNC_DRUID_PROVIDER_DESC_FILE(prov->desc);
|
||||
|
||||
if (prov_f->cb->this_file)
|
||||
desc_f->remove_file(prov->druid->be_ctx, prov_f->cb->this_file);
|
||||
|
||||
prov_f->cb->this_file = NULL;
|
||||
gnc_dpfg_end_glob(prov_f);
|
||||
}
|
||||
|
||||
/* Return TRUE if we have a valid file... */
|
||||
static gboolean
|
||||
gnc_dpfg_next_file(GNCDruidProvider *prov, const gchar *filename)
|
||||
{
|
||||
GNCDruidProviderFileGnome *prov_f = GNC_DRUID_PROVIDER_FILE_GNOME(prov);
|
||||
gboolean res;
|
||||
|
||||
prov_f->cb->filename = filename;
|
||||
res = prov->desc->next_cb(&(prov_f->cb->parent));
|
||||
|
||||
if (!res)
|
||||
gnc_error_dialog(GTK_WIDGET(prov_f->page),
|
||||
_("Failed to process file: %s"), filename);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Return TRUE if we have a valid file... */
|
||||
static gboolean
|
||||
gnc_dpfg_next_glob(GNCDruidProvider* prov)
|
||||
{
|
||||
GNCDruidProviderFileGnome *prov_f = GNC_DRUID_PROVIDER_FILE_GNOME(prov);
|
||||
gboolean res = FALSE;
|
||||
|
||||
if (!prov_f->globbed)
|
||||
return FALSE;
|
||||
|
||||
while (prov_f->count < prov_f->glob.gl_pathc)
|
||||
{
|
||||
res = gnc_dpfg_next_file(prov, prov_f->glob.gl_pathv[prov_f->count++]);
|
||||
if (res)
|
||||
return res;
|
||||
}
|
||||
|
||||
/* At this point we've reached the end of the glob */
|
||||
gnc_dpfg_end_glob(prov_f);
|
||||
return res;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GLOB_H
|
||||
static int
|
||||
gnc_dpfg_file_err(const char *path, int err)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = gnc_ok_cancel_dialog(NULL, GTK_RESPONSE_OK,
|
||||
_("Failed to open file: %s: %s"), path, strerror(err));
|
||||
|
||||
return (res == GTK_RESPONSE_OK ? 0 : 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Return TRUE if we have a valid file... */
|
||||
static gboolean
|
||||
gnc_dpfg_start_glob(GNCDruidProvider* prov, const char* filename)
|
||||
{
|
||||
GNCDruidProviderFileGnome *prov_f = GNC_DRUID_PROVIDER_FILE_GNOME(prov);
|
||||
int err;
|
||||
|
||||
g_assert(prov_f->globbed == FALSE);
|
||||
#ifdef HAVE_GLOB_H
|
||||
err = glob(filename, GLOB_NOCHECK, gnc_dpfg_file_err, &prov_f->glob);
|
||||
#else
|
||||
/* glob(3) was not available. */
|
||||
err = -1;
|
||||
#endif
|
||||
prov_f->count = 0;
|
||||
|
||||
if (!err)
|
||||
prov_f->globbed = TRUE;
|
||||
|
||||
return gnc_dpfg_next_glob(prov);
|
||||
}
|
||||
|
||||
static GNCDruidPage*
|
||||
gnc_dp_file_gnome_first_page(GNCDruidProvider* prov)
|
||||
{
|
||||
GNCDruidProviderDescFile *desc_f = GNC_DRUID_PROVIDER_DESC_FILE(prov->desc);
|
||||
gboolean res = FALSE;
|
||||
|
||||
if (desc_f->glob)
|
||||
res = gnc_dpfg_next_glob(prov);
|
||||
if (res)
|
||||
return NULL;
|
||||
|
||||
return prov->pages->data;
|
||||
}
|
||||
|
||||
static GNCDruidPage*
|
||||
gnc_dp_file_gnome_next_page(GNCDruidProvider* prov)
|
||||
{
|
||||
GNCDruidProviderFileGnome *prov_f = GNC_DRUID_PROVIDER_FILE_GNOME(prov);
|
||||
GNCDruidProviderDescFile *desc_f = GNC_DRUID_PROVIDER_DESC_FILE(prov->desc);
|
||||
gchar *filename;
|
||||
gboolean res;
|
||||
|
||||
filename = gtk_file_chooser_get_filename(prov_f->file_entry);
|
||||
|
||||
if (desc_f->glob)
|
||||
res = gnc_dpfg_start_glob(prov, filename);
|
||||
else
|
||||
res = gnc_dpfg_next_file(prov, filename);
|
||||
|
||||
g_free(filename);
|
||||
|
||||
if (res)
|
||||
return NULL;
|
||||
|
||||
return prov->pages->data;
|
||||
}
|
||||
|
||||
static GNCDruidPage*
|
||||
gnc_dpfg_back_to_multifile(GNCDruidProvider* prov, GNCDruidPage *default_page)
|
||||
{
|
||||
GNCDruidProviderDescFile *desc_f = GNC_DRUID_PROVIDER_DESC_FILE(prov->desc);
|
||||
|
||||
gnc_dpfg_del_file(prov);
|
||||
|
||||
if (desc_f->glob && desc_f->multifile_provider &&
|
||||
desc_f->multifile_provider->get_files(prov->druid->be_ctx))
|
||||
{
|
||||
gnc_druid_jump_to_provider(prov->druid,
|
||||
desc_f->multifile_provider->parent.provider);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return default_page;
|
||||
}
|
||||
|
||||
static GNCDruidPage*
|
||||
gnc_dp_file_gnome_last_page(GNCDruidProvider* prov)
|
||||
{
|
||||
return gnc_dpfg_back_to_multifile(prov, prov->pages->data);
|
||||
}
|
||||
|
||||
static GNCDruidPage*
|
||||
gnc_dp_file_gnome_prev_page(GNCDruidProvider* prov)
|
||||
{
|
||||
return gnc_dpfg_back_to_multifile(prov, NULL);
|
||||
}
|
||||
|
||||
static GNCDruidProvider*
|
||||
gnc_druid_pf_gnome_build(GNCDruid* druid, GNCDruidProviderDesc* desc)
|
||||
{
|
||||
GNCDruidProvider *prov_base;
|
||||
GNCDruidProviderFileGnome *prov;
|
||||
GNCDruidProviderDescFile *desc_f;
|
||||
GNCDruidProviderFileCB *cb;
|
||||
GnomeDruidPageStandard *page;
|
||||
GtkFileChooser *file_entry;
|
||||
GtkWidget *label;
|
||||
|
||||
/* verify that this is the correct provider descriptor */
|
||||
g_return_val_if_fail(IS_GNC_DRUID_PROVIDER_DESC_FILE(desc), NULL);
|
||||
desc_f = GNC_DRUID_PROVIDER_DESC_FILE(desc);
|
||||
|
||||
g_return_val_if_fail(desc->next_cb, NULL);
|
||||
g_return_val_if_fail(desc_f->remove_file, NULL);
|
||||
|
||||
/* Build the provider */
|
||||
prov = GNC_DRUID_PROVIDER_FILE_GNOME(g_object_new(G_TYPE_GNC_DRUID_PROVIDER_FILE_GNOME, NULL));
|
||||
g_assert(prov);
|
||||
prov_base = GNC_DRUID_PROVIDER(prov);
|
||||
|
||||
/* Build the callback object. */
|
||||
cb = gnc_druid_provider_file_cb_new();
|
||||
g_assert(cb);
|
||||
cb->parent.prov_ctx = prov_base;
|
||||
cb->parent.druid_ctx = druid;
|
||||
prov->cb = cb;
|
||||
|
||||
/* Build the Druid Page */
|
||||
page = GNOME_DRUID_PAGE_STANDARD(gnome_druid_page_standard_new());
|
||||
|
||||
/* Remember this page for later */
|
||||
g_assert(page);
|
||||
prov->page = GNOME_DRUID_PAGE(page);
|
||||
prov_base->pages = g_list_prepend(NULL, page);
|
||||
|
||||
/* Build the label */
|
||||
label = gtk_label_new(desc_f->text);
|
||||
gtk_box_pack_start(GTK_BOX(page->vbox), label, FALSE, FALSE, 0);
|
||||
|
||||
/* Build the file entry */
|
||||
file_entry = GTK_FILE_CHOOSER(gtk_file_chooser_widget_new(GTK_FILE_CHOOSER_ACTION_OPEN));
|
||||
g_assert(file_entry);
|
||||
prov->file_entry = file_entry;
|
||||
gtk_file_chooser_set_current_folder(file_entry, desc_f->last_dir);
|
||||
gtk_box_pack_start(GTK_BOX(page->vbox), GTK_WIDGET(file_entry), TRUE, TRUE, 0);
|
||||
|
||||
/* Set the page properties */
|
||||
if (desc->title)
|
||||
gnome_druid_page_standard_set_title(page, desc->title);
|
||||
|
||||
/* Show the page */
|
||||
gtk_widget_show_all(GTK_WIDGET(page));
|
||||
|
||||
/* Return the provider instance */
|
||||
return prov_base;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_druid_provider_file_gnome_register(void)
|
||||
{
|
||||
gnc_druid_provider_register(GNC_DRUID_GNOME_UI, GNC_DRUID_PROVIDER_TYPE_FILE,
|
||||
gnc_druid_pf_gnome_build);
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
|
||||
|
||||
#ifndef GNC_DRUID_PROVIDER_FILE_GNOME_H
|
||||
#define GNC_DRUID_PROVIDER_FILE_GNOME_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
//extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GLOB_H
|
||||
# include <glob.h>
|
||||
#else
|
||||
# include <stddef.h> /* for size_t */
|
||||
typedef struct
|
||||
{
|
||||
size_t gl_pathc; /* Count of paths matched so far */
|
||||
char **gl_pathv; /* List of matched pathnames. */
|
||||
size_t gl_offs; /* Slots to reserve in `gl_pathv'. */
|
||||
} glob_t;
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <libgnomeui/libgnomeui.h>
|
||||
#include "gnc-druid.h"
|
||||
#include "gnc-druid-provider-file-cb.h"
|
||||
|
||||
#define G_TYPE_GNC_DRUID_PROVIDER_FILE_GNOME (gnc_druid_provider_file_gnome_get_type())
|
||||
#define GNC_DRUID_PROVIDER_FILE_GNOME(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_GNC_DRUID_PROVIDER_FILE_GNOME, GNCDruidProviderFileGnome)
|
||||
#define GNC_DRUID_PROVIDER_FILE_GNOME_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_GNC_DRUID_PROVIDER_FILE_GNOME, GNCDruidProviderFileGnomeClass)
|
||||
#define IS_GNC_DRUID_PROVIDER_FILE_GNOME(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_GNC_DRUID_PROVIDER_FILE_GNOME)
|
||||
#define IS_GNC_DRUID_PROVIDER_FILE_GNOME_CLASS(klass) G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_GNC_DRUID_PROVIDER_FILE_GNOME)
|
||||
#define GNC_DRUID_PROVIDER_FILE_GNOME_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), G_TYPE_GNC_DRUID_PROVIDER_FILE_GNOME, GNCDruidProviderFileGnomeClass))
|
||||
|
||||
typedef struct _GNCDruidProviderFileGnome GNCDruidProviderFileGnome;
|
||||
typedef struct _GNCDruidProviderFileGnomeClass GNCDruidProviderFileGnomeClass;
|
||||
|
||||
struct _GNCDruidProviderFileGnome
|
||||
{
|
||||
GNCDruidProvider parent;
|
||||
|
||||
GnomeDruidPage* page;
|
||||
GtkFileChooser* file_entry;
|
||||
|
||||
GNCDruidProviderFileCB* cb;
|
||||
|
||||
size_t count;
|
||||
glob_t glob;
|
||||
gboolean globbed;
|
||||
};
|
||||
|
||||
struct _GNCDruidProviderFileGnomeClass
|
||||
{
|
||||
GNCDruidProviderClass parent_class;
|
||||
};
|
||||
|
||||
GType gnc_druid_provider_file_gnome_get_type(void);
|
||||
void gnc_druid_provider_file_gnome_register(void);
|
||||
|
||||
/* methods */
|
||||
|
||||
#ifdef __cplusplus
|
||||
//}
|
||||
#endif
|
||||
|
||||
#endif /* GNC_DRUID_PROVIDER_FILE_GNOME_H */
|
@ -1,315 +0,0 @@
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include "gnc-druid-gnome-ui.h"
|
||||
#include "gnc-druid-provider-file-gnome.h"
|
||||
#include "gnc-druid-provider-multifile-gnome.h"
|
||||
#include "gnc-druid-provider-desc-multifile.h"
|
||||
|
||||
#include "gnc-basic-gobject.h"
|
||||
#include "dialog-utils.h"
|
||||
#include "gnc-ui.h"
|
||||
#include "gnc-gui-query.h"
|
||||
|
||||
enum file_cols
|
||||
{
|
||||
FILE_COL_FILENAME = 0,
|
||||
FILE_COL_POINTER,
|
||||
NUM_FILE_COLS
|
||||
};
|
||||
|
||||
static void gnc_druid_provider_multifile_gnome_class_init (GNCDruidProviderMultifileGnomeClass *class);
|
||||
static void gnc_druid_provider_multifile_gnome_finalize (GObject *obj);
|
||||
|
||||
static GNCDruidPage* gnc_dp_multifile_gnome_first_page(GNCDruidProvider*);
|
||||
static GNCDruidPage* gnc_dp_multifile_gnome_last_page(GNCDruidProvider*);
|
||||
static GNCDruidPage* gnc_dp_multifile_gnome_next_page(GNCDruidProvider*);
|
||||
|
||||
static GNCDruidProviderClass *parent_class;
|
||||
|
||||
GNC_BASIC_GOBJECT_TYPE(GNCDruidProviderMultifileGnome, GNCDruidProviderMultifileGnomeClass,
|
||||
G_TYPE_GNC_DRUID_PROVIDER,
|
||||
gnc_druid_provider_multifile_gnome_class_init, NULL,
|
||||
gnc_druid_provider_multifile_gnome_get_type)
|
||||
|
||||
static void
|
||||
gnc_druid_provider_multifile_gnome_class_init (GNCDruidProviderMultifileGnomeClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
GNCDruidProviderClass *gdp_class = (GNCDruidProviderClass*)klass;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gnc_druid_provider_multifile_gnome_finalize;
|
||||
|
||||
/* override methods */
|
||||
gdp_class->first_page = gnc_dp_multifile_gnome_first_page;
|
||||
gdp_class->last_page = gnc_dp_multifile_gnome_last_page;
|
||||
gdp_class->next_page = gnc_dp_multifile_gnome_next_page;
|
||||
gdp_class->prev_page = gnc_dp_multifile_gnome_last_page;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_druid_provider_multifile_gnome_finalize (GObject *obj)
|
||||
{
|
||||
//GNCDruidProviderMultifileGnome *prov_mf = (GNCDruidProviderMultifileGnome *)obj;
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_dpmfg_select_file_cb(GtkTreeSelection *selection,
|
||||
GNCDruidProviderMultifileGnome *prov_mf)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
|
||||
if (gtk_tree_selection_get_selected(selection, &model, &iter))
|
||||
{
|
||||
gtk_tree_model_get(model, &iter,
|
||||
FILE_COL_POINTER, &prov_mf->selected_file,
|
||||
-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
prov_mf->selected_file = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_dpmfg_refresh_list(GNCDruidProviderMultifileGnome *prov_mf)
|
||||
{
|
||||
GNCDruidProviderDescMultifile *desc_mf =
|
||||
GNC_DRUID_PROVIDER_DESC_MULTIFILE(prov_mf->parent.desc);
|
||||
GtkTreeView *view = GTK_TREE_VIEW(prov_mf->file_view);
|
||||
GtkListStore *store;
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path;
|
||||
GtkTreeSelection *selection;
|
||||
GtkTreeRowReference *reference = NULL;
|
||||
GList *list;
|
||||
const gchar* filename;
|
||||
gpointer be_ctx = prov_mf->parent.druid->be_ctx;
|
||||
|
||||
store = GTK_LIST_STORE(gtk_tree_view_get_model(view));
|
||||
gtk_list_store_clear(store);
|
||||
|
||||
for (list = desc_mf->get_files(be_ctx); list; list = list->next)
|
||||
{
|
||||
filename = desc_mf->get_filename(be_ctx, list->data);
|
||||
|
||||
gtk_list_store_prepend(store, &iter);
|
||||
gtk_list_store_set(store, &iter,
|
||||
FILE_COL_FILENAME, filename,
|
||||
FILE_COL_POINTER, list->data,
|
||||
-1);
|
||||
if (prov_mf->selected_file == list->data)
|
||||
{
|
||||
path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
|
||||
reference = gtk_tree_row_reference_new(GTK_TREE_MODEL(store), path);
|
||||
gtk_tree_path_free(path);
|
||||
}
|
||||
}
|
||||
|
||||
if (reference)
|
||||
{
|
||||
path = gtk_tree_row_reference_get_path(reference);
|
||||
gtk_tree_row_reference_free(reference);
|
||||
if (path)
|
||||
{
|
||||
selection = gtk_tree_view_get_selection(view);
|
||||
gtk_tree_selection_select_path(selection, path);
|
||||
gtk_tree_view_scroll_to_cell(view, path, NULL, TRUE, 0.5, 0.0);
|
||||
gtk_tree_path_free(path);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
prov_mf->selected_file = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static GNCDruidPage*
|
||||
gnc_dpmfg_jump_to_file(GNCDruidProvider *prov)
|
||||
{
|
||||
GNCDruidProviderDescMultifile *desc_mf =
|
||||
GNC_DRUID_PROVIDER_DESC_MULTIFILE(prov->desc);
|
||||
|
||||
gnc_druid_jump_to_provider(prov->druid, desc_mf->file_provider->parent.provider);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_dpmfg_load_another_cb(GtkButton *button, gpointer user_data)
|
||||
{
|
||||
GNCDruidProvider *prov = user_data;
|
||||
|
||||
gnc_dpmfg_jump_to_file(prov);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_dpmfg_remove_file_cb(GtkButton *button, gpointer user_data)
|
||||
{
|
||||
GNCDruidProviderMultifileGnome *prov_mf = user_data;
|
||||
GNCDruidProviderDescMultifile *desc_mf =
|
||||
GNC_DRUID_PROVIDER_DESC_MULTIFILE(prov_mf->parent.desc);
|
||||
GNCDruidProviderDescFile *desc_f = desc_mf->file_provider;
|
||||
gpointer be_ctx = prov_mf->parent.druid->be_ctx;
|
||||
|
||||
if (!prov_mf->selected_file)
|
||||
return;
|
||||
|
||||
desc_f->remove_file(be_ctx, prov_mf->selected_file);
|
||||
|
||||
/* If we have no files, jump to the file provider. Otherwise refresh the page */
|
||||
if (! desc_mf->get_files(be_ctx))
|
||||
gnc_dpmfg_jump_to_file(&prov_mf->parent);
|
||||
else
|
||||
gnc_dpmfg_refresh_list(prov_mf);
|
||||
}
|
||||
|
||||
static GNCDruidPage*
|
||||
gnc_dp_multifile_gnome_first_page(GNCDruidProvider* prov)
|
||||
{
|
||||
GNCDruidProviderDescMultifile *desc_mf =
|
||||
GNC_DRUID_PROVIDER_DESC_MULTIFILE(prov->desc);
|
||||
GNCDruidProviderFileGnome *prov_f =
|
||||
GNC_DRUID_PROVIDER_FILE_GNOME(desc_mf->file_provider->parent.provider);
|
||||
|
||||
/* If we're globbing and have more data to read, jump back to the file provider */
|
||||
if (prov_f->globbed && prov_f->count < prov_f->glob.gl_pathc)
|
||||
return gnc_dpmfg_jump_to_file(prov);
|
||||
|
||||
/* Otherwise, clear out this_file, refresh the list and show the page */
|
||||
prov_f->cb->this_file = NULL;
|
||||
gnc_dpmfg_refresh_list(GNC_DRUID_PROVIDER_MULTIFILE_GNOME(prov));
|
||||
return prov->pages->data;
|
||||
}
|
||||
|
||||
static GNCDruidPage*
|
||||
gnc_dp_multifile_gnome_last_page(GNCDruidProvider* prov)
|
||||
{
|
||||
GNCDruidProviderDescMultifile *desc_mf =
|
||||
GNC_DRUID_PROVIDER_DESC_MULTIFILE(prov->desc);
|
||||
|
||||
/* If we have no files, just back up */
|
||||
if (! desc_mf->get_files(prov->druid->be_ctx))
|
||||
return NULL;
|
||||
|
||||
/* Otherwise, refresh the list and show the page. XXX: Do we need to refresh? */
|
||||
gnc_dpmfg_refresh_list(GNC_DRUID_PROVIDER_MULTIFILE_GNOME(prov));
|
||||
return prov->pages->data;
|
||||
}
|
||||
|
||||
static GNCDruidPage*
|
||||
gnc_dp_multifile_gnome_next_page(GNCDruidProvider* prov)
|
||||
{
|
||||
GNCDruidProviderMultifileGnome *prov_mf =
|
||||
GNC_DRUID_PROVIDER_MULTIFILE_GNOME(prov);
|
||||
|
||||
/* Ignore the return -- we don't care what they say */
|
||||
prov->desc->next_cb(prov_mf->cb);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static GNCDruidProvider*
|
||||
gnc_druid_pf_gnome_build(GNCDruid* druid, GNCDruidProviderDesc* desc)
|
||||
{
|
||||
GNCDruidProvider *prov_base;
|
||||
GNCDruidProviderMultifileGnome *prov;
|
||||
GNCDruidProviderDescMultifile *desc_mf;
|
||||
GNCDruidCB *cb;
|
||||
GtkWidget *window, *page, *view, *button1, *button2, *label;
|
||||
GladeXML *xml;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkCellRenderer *renderer;
|
||||
GtkListStore *store;
|
||||
GtkTreeSelection *selection;
|
||||
|
||||
/* verify that this is the correct provider descriptor */
|
||||
g_return_val_if_fail(IS_GNC_DRUID_PROVIDER_DESC_MULTIFILE(desc), NULL);
|
||||
desc_mf = GNC_DRUID_PROVIDER_DESC_MULTIFILE(desc);
|
||||
|
||||
g_return_val_if_fail(desc->next_cb, NULL);
|
||||
g_return_val_if_fail(desc_mf->file_provider, NULL);
|
||||
g_return_val_if_fail(desc_mf->get_files, NULL);
|
||||
g_return_val_if_fail(desc_mf->get_filename, NULL);
|
||||
|
||||
/* Build the provider */
|
||||
prov = GNC_DRUID_PROVIDER_MULTIFILE_GNOME(g_object_new(G_TYPE_GNC_DRUID_PROVIDER_MULTIFILE_GNOME, NULL));
|
||||
g_assert(prov);
|
||||
prov_base = GNC_DRUID_PROVIDER(prov);
|
||||
|
||||
/* Build the callback object. */
|
||||
cb = gnc_druid_cb_new();
|
||||
g_assert(cb);
|
||||
cb->prov_ctx = prov_base;
|
||||
cb->druid_ctx = druid;
|
||||
prov->cb = cb;
|
||||
|
||||
/* Build the Druid Page */
|
||||
xml = gnc_glade_xml_new("druid-provider-multifile.glade",
|
||||
"Multifile Provider Window");
|
||||
g_assert(xml);
|
||||
window = glade_xml_get_widget(xml, "Multifile Provider Window");
|
||||
page = glade_xml_get_widget(xml, "Multifile Provider Page");
|
||||
view = glade_xml_get_widget(xml, "file_view");
|
||||
button1 = glade_xml_get_widget(xml, "load_button");
|
||||
button2 = glade_xml_get_widget(xml, "unload_button");
|
||||
label = glade_xml_get_widget(xml, "instruction_label");
|
||||
|
||||
g_object_ref(page);
|
||||
gtk_container_remove(GTK_CONTAINER(window), page);
|
||||
gtk_widget_destroy(window);
|
||||
|
||||
/* XXX: Am I going to have to unref this later? */
|
||||
|
||||
/* Remember this page for later */
|
||||
g_assert(page);
|
||||
prov->page = GNOME_DRUID_PAGE(page);
|
||||
prov_base->pages = g_list_prepend(NULL, page);
|
||||
prov->file_view = view;
|
||||
|
||||
/* Set up the file view */
|
||||
store = gtk_list_store_new (NUM_FILE_COLS, G_TYPE_STRING, G_TYPE_POINTER);
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store));
|
||||
g_object_unref(store);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes("", renderer,
|
||||
"text", FILE_COL_FILENAME,
|
||||
NULL);
|
||||
gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
|
||||
|
||||
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
|
||||
g_signal_connect(selection, "changed",
|
||||
(GCallback)gnc_dpmfg_select_file_cb, prov);
|
||||
|
||||
/* Set the page properties */
|
||||
g_signal_connect(G_OBJECT(button1), "clicked",
|
||||
(GCallback)gnc_dpmfg_load_another_cb, prov);
|
||||
g_signal_connect(G_OBJECT(button2), "clicked",
|
||||
(GCallback)gnc_dpmfg_remove_file_cb, prov);
|
||||
|
||||
if (desc->title)
|
||||
gnome_druid_page_standard_set_title(GNOME_DRUID_PAGE_STANDARD(page),
|
||||
desc->title);
|
||||
|
||||
if (desc_mf->text)
|
||||
gtk_label_set_text(GTK_LABEL(label), desc_mf->text);
|
||||
|
||||
/* Show the page */
|
||||
gtk_widget_show_all(GTK_WIDGET(page));
|
||||
|
||||
/* Return the provider instance */
|
||||
return prov_base;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_druid_provider_multifile_gnome_register(void)
|
||||
{
|
||||
gnc_druid_provider_register(GNC_DRUID_GNOME_UI, GNC_DRUID_PROVIDER_TYPE_MULTIFILE,
|
||||
gnc_druid_pf_gnome_build);
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
|
||||
|
||||
#ifndef GNC_DRUID_PROVIDER_MULTIFILE_GNOME_H
|
||||
#define GNC_DRUID_PROVIDER_MULTIFILE_GNOME_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
//extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GLOB_H
|
||||
# include <glob.h>
|
||||
#else
|
||||
# ifndef GNC_DRUID_PROVIDER_FILE_GNOME_H
|
||||
# include <stddef.h> /* for size_t */
|
||||
typedef struct
|
||||
{
|
||||
size_t gl_pathc; /* Count of paths matched so far */
|
||||
char **gl_pathv; /* List of matched pathnames. */
|
||||
size_t gl_offs; /* Slots to reserve in `gl_pathv'. */
|
||||
} glob_t;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <libgnomeui/libgnomeui.h>
|
||||
#include "gnc-druid.h"
|
||||
|
||||
#define G_TYPE_GNC_DRUID_PROVIDER_MULTIFILE_GNOME (gnc_druid_provider_multifile_gnome_get_type())
|
||||
#define GNC_DRUID_PROVIDER_MULTIFILE_GNOME(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_GNC_DRUID_PROVIDER_MULTIFILE_GNOME, GNCDruidProviderMultifileGnome)
|
||||
#define GNC_DRUID_PROVIDER_MULTIFILE_GNOME_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_GNC_DRUID_PROVIDER_MULTIFILE_GNOME, GNCDruidProviderMultifileGnomeClass)
|
||||
#define IS_GNC_DRUID_PROVIDER_MULTIFILE_GNOME(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_GNC_DRUID_PROVIDER_MULTIFILE_GNOME)
|
||||
#define IS_GNC_DRUID_PROVIDER_MULTIFILE_GNOME_CLASS(klass) G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_GNC_DRUID_PROVIDER_MULTIFILE_GNOME)
|
||||
#define GNC_DRUID_PROVIDER_MULTIFILE_GNOME_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), G_TYPE_GNC_DRUID_PROVIDER_MULTIFILE_GNOME, GNCDruidProviderMultifileGnomeClass))
|
||||
|
||||
typedef struct _GNCDruidProviderMultifileGnome GNCDruidProviderMultifileGnome;
|
||||
typedef struct _GNCDruidProviderMultifileGnomeClass GNCDruidProviderMultifileGnomeClass;
|
||||
|
||||
struct _GNCDruidProviderMultifileGnome
|
||||
{
|
||||
GNCDruidProvider parent;
|
||||
|
||||
GnomeDruidPage* page;
|
||||
GtkWidget* file_view;
|
||||
|
||||
GNCDruidCB* cb;
|
||||
gpointer selected_file;
|
||||
};
|
||||
|
||||
struct _GNCDruidProviderMultifileGnomeClass
|
||||
{
|
||||
GNCDruidProviderClass parent_class;
|
||||
};
|
||||
|
||||
GType gnc_druid_provider_multifile_gnome_get_type(void);
|
||||
void gnc_druid_provider_multifile_gnome_register(void);
|
||||
|
||||
/* methods */
|
||||
|
||||
#ifdef __cplusplus
|
||||
//}
|
||||
#endif
|
||||
|
||||
#endif /* GNC_DRUID_PROVIDER_MULTIFILE_GNOME_H */
|
@ -17,11 +17,6 @@
|
||||
#include "qof.h"
|
||||
#include "gnc-gui-query.h"
|
||||
|
||||
#include "gnc-druid-gnome.h"
|
||||
#include "gnc-druid-provider-edge-gnome.h"
|
||||
#include "gnc-druid-provider-file-gnome.h"
|
||||
#include "gnc-druid-provider-multifile-gnome.h"
|
||||
|
||||
GNC_MODULE_API_DECL(libgncmod_gnome_utils)
|
||||
|
||||
/* version of the gnc module system interface we require */
|
||||
@ -83,12 +78,6 @@ libgncmod_gnome_utils_gnc_module_init(int refcount)
|
||||
if (refcount == 0)
|
||||
{
|
||||
gnc_options_ui_initialize ();
|
||||
|
||||
/* register the druid pieces */
|
||||
gnc_druid_gnome_register();
|
||||
gnc_druid_provider_edge_gnome_register();
|
||||
gnc_druid_provider_file_gnome_register();
|
||||
gnc_druid_provider_multifile_gnome_register();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
Loading…
Reference in New Issue
Block a user