pango_context_get_metrics (context,
widget->style->font_desc,
pango_context_get_language (context));
+
guint val = pango_font_metrics_get_descent (metrics) +
pango_font_metrics_get_ascent (metrics);
+
pango_font_metrics_unref (metrics);
- return PANGO_PIXELS (val)+2 * CELLOFFSET;
+
+ return PANGO_PIXELS (val) + 2 * CELLOFFSET;
}
}
{
GdkWindow *window = NULL;
GdkRectangle allocation;
- GtkSheetButton *button = NULL;
+
gboolean is_sensitive = FALSE;
if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return;
}
else
{
- button = xxx_column_button (sheet, column);
+ GtkSheetButton *button = xxx_column_button (sheet, column);
allocation.x = COLUMN_LEFT_XPIXEL (sheet, column) + CELL_SPACING;
if (sheet->row_titles_visible)
allocation.x -= sheet->row_title_area.width;
is_sensitive = xxx_column_is_sensitive (sheet, column);
gtk_sheet_button_draw (sheet, window, button,
is_sensitive, allocation);
+
+ /* FIXME: Not freeing this button is correct (sort of),
+ because in PSPP the model always returns a static copy */
+
+ /* gtk_sheet_button_free (button); */
+
}
}
{
GtkRequisition button_requisition;
GList *children;
+ GtkSheetButton *button = xxx_column_button (sheet, col);
gtk_sheet_button_size_request (sheet,
- xxx_column_button (sheet, col),
+ button,
&button_requisition);
+ gtk_sheet_button_free (button);
+
*requisition = button_requisition.width;
children = sheet->children;
+2008-02-03 John Darrington <john@darrington.wattle.id.au>
+
+ * psppire-case-file.c psppire-case-file.h: Dont clone the casereader
+ before creating datasheet. Add properties instead of direct code
+ in _new function.
+
+ * psppire-data-store.c: Implement proper dispose function.
+
2008-01-29 John Darrington <john@darrington.wattle.id.au>
* psppire-var-ptr.c psppire-var-ptr.h: New files
gchar *text;
GString *string ;
const gchar *target_name ;
- const gchar *expression;
+ gchar *expression;
const gchar *label;
GtkTextIter start, end;
GtkWidget *target = get_widget_assert (cd->xml, "compute-entry1");
g_string_append (string, "EXECUTE.\n");
+
+ g_free (expression);
+
text = string->str;
g_string_free (string, FALSE);
gtk_toggle_action_get_active (ta));
}
+extern PsppireDataStore *the_data_store ;
static void
file_quit (GtkCheckMenuItem *menuitem, gpointer data)
/* FIXME: Need to be more intelligent here.
Give the user the opportunity to save any unsaved data.
*/
+ g_object_unref (the_data_store);
gtk_main_quit ();
}
return object_type;
}
+/* Properties */
+enum
+{
+ PROP_0,
+ PROP_DATASHEET,
+ PROP_READER
+};
+
+
+
+
+static void
+psppire_case_file_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+
+{
+ PsppireCaseFile *cf = PSPPIRE_CASE_FILE (object);
+
+ switch (prop_id)
+ {
+ case PROP_READER:
+ cf->datasheet = datasheet_create (g_value_get_pointer (value));
+ cf->accessible = TRUE;
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ };
+}
+
+static void
+psppire_case_file_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ PsppireCaseFile *cf = PSPPIRE_CASE_FILE (object);
+
+ switch (prop_id)
+ {
+ case PROP_DATASHEET:
+ g_value_set_pointer (value, cf->datasheet);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ };
+}
+
static void
psppire_case_file_class_init (PsppireCaseFileClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GParamSpec *datasheet_spec ;
+ GParamSpec *reader_spec ;
parent_class = g_type_class_peek_parent (class);
object_class->finalize = psppire_case_file_finalize;
+ datasheet_spec =
+ g_param_spec_pointer ("datasheet",
+ "Datasheet",
+ "A pointer to the datasheet belonging to this object",
+ G_PARAM_READABLE );
+ reader_spec =
+ g_param_spec_pointer ("casereader",
+ "CaseReader",
+ "A pointer to the case reader from which this object is constructed",
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE );
+
+ object_class->set_property = psppire_case_file_set_property;
+ object_class->get_property = psppire_case_file_get_property;
+
+ g_object_class_install_property (object_class,
+ PROP_DATASHEET,
+ datasheet_spec);
+
+ g_object_class_install_property (object_class,
+ PROP_READER,
+ reader_spec);
+
signals [CASE_CHANGED] =
g_signal_new ("case-changed",
G_TYPE_FROM_CLASS (class),
* Creates a new #PsppireCaseFile.
*/
PsppireCaseFile*
-psppire_case_file_new (const struct casereader *reader)
+psppire_case_file_new (struct casereader *reader)
{
- PsppireCaseFile *cf = g_object_new (G_TYPE_PSPPIRE_CASE_FILE, NULL);
-
- cf->datasheet = datasheet_create (casereader_clone (reader));
- cf->accessible = TRUE;
-
- return cf;
+ return g_object_new (G_TYPE_PSPPIRE_CASE_FILE,
+ "casereader", reader,
+ NULL);
}
{
union value *values = xcalloc (n_values, sizeof *values);
datasheet_insert_columns (cf->datasheet, values, n_values, where);
- free (values);
+ free (values);
}
return TRUE;
/* -- PsppireCaseFile --- */
GType psppire_case_file_get_type (void);
-PsppireCaseFile *psppire_case_file_new (const struct casereader *);
+PsppireCaseFile *psppire_case_file_new (struct casereader *);
gboolean psppire_case_file_insert_case (PsppireCaseFile *cf, struct ccase *c, casenumber row);
static void psppire_data_store_sheet_row_init (GSheetRowIface *iface);
static void psppire_data_store_finalize (GObject *object);
+static void psppire_data_store_dispose (GObject *object);
static gboolean psppire_data_store_clear_datum (GSheetModel *model,
glong row, glong column);
object_class = (GObjectClass*) class;
object_class->finalize = psppire_data_store_finalize;
+ object_class->dispose = psppire_data_store_dispose;
signals [FONT_CHANGED] =
g_signal_new ("font_changed",
psppire_data_store_init (PsppireDataStore *data_store)
{
data_store->dict = 0;
- data_store->case_file = 0;
+ data_store->case_file = NULL;
data_store->width_of_m = 10;
-
-
+ data_store->dispose_has_run = FALSE;
}
const PangoFontDescription *
PsppireCaseFile *cf)
{
gint i;
- if ( ds->case_file)
- {
- g_object_unref (ds->case_file);
- }
+ if ( ds->case_file) g_object_unref (ds->case_file);
+
ds->case_file = cf;
(* parent_class->finalize) (object);
}
+
+static void
+psppire_data_store_dispose (GObject *object)
+{
+ PsppireDataStore *ds = PSPPIRE_DATA_STORE (object);
+
+ if (ds->dispose_has_run)
+ return;
+
+ if (ds->case_file) g_object_unref (ds->case_file);
+
+ /* must chain up */
+ (* parent_class->dispose) (object);
+
+ ds->dispose_has_run = TRUE;
+}
+
+
gboolean
psppire_data_store_delete_cases (PsppireDataStore *ds,
casenumber first, casenumber count)
GObject parent;
/*< private >*/
+ gboolean dispose_has_run ;
PsppireDict *dict;
PsppireCaseFile *case_file;
const PangoFontDescription *font_desc;
g_main_loop_run (dialog->loop);
+ g_main_loop_unref (dialog->loop);
+
return dialog->response;
}