#include "psppire-spreadsheet-model.h"
+#include "data/spreadsheet-reader.h"
+
static void psppire_spreadsheet_model_init (PsppireSpreadsheetModel *spreadsheetModel);
static void psppire_spreadsheet_model_class_init (PsppireSpreadsheetModelClass *class);
}
+/* Properties */
+enum
+{
+ PROP_0,
+ PROP_SPREADSHEET
+};
+
+
+static void
+psppire_spreadsheet_model_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ PsppireSpreadsheetModel *spreadsheetModel = PSPPIRE_SPREADSHEET_MODEL (object);
+
+ switch (prop_id)
+ {
+ case PROP_SPREADSHEET:
+ spreadsheetModel->spreadsheet = g_value_get_pointer (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ };
+}
+
+
+
static void
psppire_spreadsheet_model_dispose (GObject *object)
{
{
GObjectClass *object_class;
+ GParamSpec *spreadsheet_spec =
+ g_param_spec_pointer ("spreadsheet",
+ "Spreadsheet",
+ "The spreadsheet that this model represents",
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE);
+
parent_class = g_type_class_peek_parent (class);
object_class = (GObjectClass*) class;
+ object_class->set_property = psppire_spreadsheet_model_set_property;
+
+ g_object_class_install_property (object_class,
+ PROP_SPREADSHEET,
+ spreadsheet_spec);
+
+
+
object_class->finalize = psppire_spreadsheet_model_finalize;
object_class->dispose = psppire_spreadsheet_model_dispose;
}
GtkTreeModel*
-psppire_spreadsheet_model_new (void)
+psppire_spreadsheet_model_new (struct spreadsheet *sp)
{
- return g_object_new (psppire_spreadsheet_model_get_type (), NULL);
+ return g_object_new (psppire_spreadsheet_model_get_type (),
+ "spreadsheet", sp,
+ NULL);
}
g_print ("%s %d\n", __FUNCTION__, iter->user_data);
- if ( iter->user_data >= 5 - 1)
+ if ( iter->user_data >= spreadsheetModel->spreadsheet->sheets - 1)
return FALSE;
iter->user_data++;
if ( parent )
return FALSE;
- if ( n >= 5)
+ if ( n >= spreadsheetModel->spreadsheet->sheets)
return FALSE;
iter->stamp = spreadsheetModel->stamp;
- /*
- iter->user_data = psppire_dict_get_variable (dict, n);
-
- if ( !iter->user_data)
- return FALSE;
- */
return TRUE;
}
typedef struct _PsppireSpreadsheetModelClass PsppireSpreadsheetModelClass;
+struct spreadsheet;
+
struct _PsppireSpreadsheetModel
{
GObject parent;
/*< private >*/
gint stamp;
+ struct spreadsheet *spreadsheet;
gboolean dispose_has_run ;
};
GType psppire_spreadsheet_model_get_type (void) G_GNUC_CONST;
-GtkTreeModel * psppire_spreadsheet_model_new (void);
+
+GtkTreeModel * psppire_spreadsheet_model_new (struct spreadsheet *sp);
G_END_DECLS
#include "psppire-spreadsheet-model.h"
+#include "data/gnumeric-reader.h"
+
#define N 10
static GtkListStore *
return list_store;
}
-
-
int
main (int argc, char *argv[] )
{
GtkTreeModel *tm;
gtk_init (&argc, &argv);
+ if ( argc < 2)
+ g_error ("Usage: prog file\n");
+
+ struct spreadsheet *sp = gnumeric_probe (argv[1]);
+
+ if (sp == NULL)
+ {
+ g_error ("%s is not a gnumeric file\n", argv[1]);
+ return 0;
+ }
- tm = psppire_spreadsheet_model_new ();
+ tm = psppire_spreadsheet_model_new (sp);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width (GTK_CONTAINER (window), 10);