[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pspp-cvs] pspp lib/gtksheet/ChangeLog lib/gtksheet/gtkshe...
From: |
John Darrington |
Subject: |
[Pspp-cvs] pspp lib/gtksheet/ChangeLog lib/gtksheet/gtkshe... |
Date: |
Wed, 20 Feb 2008 10:04:12 +0000 |
CVSROOT: /sources/pspp
Module name: pspp
Changes by: John Darrington <jmd> 08/02/20 10:04:12
Modified files:
lib/gtksheet : ChangeLog gtksheet.c gtksheet.h
src/ui/gui : data-sheet.c var-sheet.c var-sheet.h
Log message:
Cleanup gtksheet and add features to var-sheet.[ch]
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/lib/gtksheet/ChangeLog?cvsroot=pspp&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/pspp/lib/gtksheet/gtksheet.c?cvsroot=pspp&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/pspp/lib/gtksheet/gtksheet.h?cvsroot=pspp&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/data-sheet.c?cvsroot=pspp&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/var-sheet.c?cvsroot=pspp&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/var-sheet.h?cvsroot=pspp&r1=1.8&r2=1.9
Patches:
Index: lib/gtksheet/ChangeLog
===================================================================
RCS file: /sources/pspp/pspp/lib/gtksheet/ChangeLog,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- lib/gtksheet/ChangeLog 8 Feb 2008 23:30:12 -0000 1.20
+++ lib/gtksheet/ChangeLog 20 Feb 2008 10:04:11 -0000 1.21
@@ -1,3 +1,8 @@
+2008-02-20 John Darrington <address@hidden>
+
+ * gtksheet.c gtksheet.h: Removed some unused signals.
+ Made the models properties of the widget.
+
2008-02-08 John Darrington <address@hidden>
* gtksheet.c: Removed the sheet_locked feature, which we never
Index: lib/gtksheet/gtksheet.c
===================================================================
RCS file: /sources/pspp/pspp/lib/gtksheet/gtksheet.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- lib/gtksheet/gtksheet.c 17 Feb 2008 05:37:49 -0000 1.35
+++ lib/gtksheet/gtksheet.c 20 Feb 2008 10:04:11 -0000 1.36
@@ -106,8 +106,6 @@
static void gtk_sheet_update_primary_selection (GtkSheet *sheet);
-
-
static void gtk_sheet_column_title_button_draw (GtkSheet *sheet, gint column);
static void gtk_sheet_row_title_button_draw (GtkSheet *sheet, gint row);
@@ -115,8 +113,8 @@
static gboolean gtk_sheet_cell_empty (const GtkSheet *sheet, gint row, gint
col);
-static inline
-void dispose_string (const GtkSheet *sheet, gchar *text)
+static inline void
+dispose_string (const GtkSheet *sheet, gchar *text)
{
GSheetModel *model = gtk_sheet_get_model (sheet);
@@ -615,7 +613,7 @@
static void gtk_sheet_class_init (GtkSheetClass * klass);
static void gtk_sheet_init (GtkSheet * sheet);
-static void gtk_sheet_destroy (GtkObject * object);
+static void gtk_sheet_dispose (GObject * object);
static void gtk_sheet_finalize (GObject * object);
static void gtk_sheet_style_set (GtkWidget *widget,
GtkStyle *previous_style);
@@ -695,7 +693,7 @@
static void gtk_sheet_entry_changed (GtkWidget *widget,
gpointer data);
-static gboolean gtk_sheet_deactivate_cell (GtkSheet *sheet);
+static void gtk_sheet_deactivate_cell (GtkSheet *sheet);
static void gtk_sheet_hide_active_cell (GtkSheet *sheet);
static gboolean gtk_sheet_activate_cell (GtkSheet *sheet,
gint row, gint col);
@@ -805,11 +803,7 @@
TRAVERSE,
DEACTIVATE,
ACTIVATE,
- SET_CELL,
- CLEAR_CELL,
CHANGED,
- NEW_COL_WIDTH,
- NEW_ROW_HEIGHT,
LAST_SIGNAL
};
@@ -882,17 +876,84 @@
return sheet_range_type;
}
+
+static void column_titles_changed (GtkWidget *w, gint first, gint n_columns,
gpointer data);
+
+/* Properties */
+enum
+{
+ PROP_0,
+ PROP_ROW_GEO,
+ PROP_COL_GEO,
+ PROP_MODEL
+};
+
+static void
+gtk_sheet_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+
+{
+ GtkSheet *sheet = GTK_SHEET (object);
+
+ switch (prop_id)
+ {
+ case PROP_ROW_GEO:
+ sheet->row_geometry = g_value_get_pointer (value);
+ break;
+ case PROP_COL_GEO:
+ sheet->column_geometry = g_value_get_pointer (value);
+ if ( sheet->column_geometry)
+ g_signal_connect (sheet->column_geometry, "columns_changed",
+ G_CALLBACK (column_titles_changed), sheet);
+ break;
+ case PROP_MODEL:
+ gtk_sheet_set_model (sheet, g_value_get_pointer (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ };
+}
+
+static void
+gtk_sheet_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtkSheet *sheet = GTK_SHEET (object);
+
+ switch (prop_id)
+ {
+ case PROP_ROW_GEO:
+ g_value_set_pointer (value, sheet->row_geometry);
+ break;
+ case PROP_COL_GEO:
+ g_value_set_pointer (value, sheet->column_geometry);
+ break;
+ case PROP_MODEL:
+ g_value_set_pointer (value, sheet->model);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ };
+}
+
+
static void
gtk_sheet_class_init (GtkSheetClass * klass)
{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- object_class = (GtkObjectClass *) klass;
- widget_class = (GtkWidgetClass *) klass;
- container_class = (GtkContainerClass *) klass;
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ GParamSpec *row_geo_spec ;
+ GParamSpec *col_geo_spec ;
+ GParamSpec *model_spec ;
+
+ GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
+ GtkContainerClass *container_class = (GtkContainerClass *) klass;
parent_class = g_type_class_peek_parent (klass);
@@ -909,7 +970,7 @@
G_SIGNAL_RUN_LAST,
offsetof (GtkSheetClass, select_row),
NULL, NULL,
- gtkextra_VOID__INT,
+ g_cclosure_marshal_VOID__INT,
G_TYPE_NONE,
1,
G_TYPE_INT);
@@ -928,7 +989,7 @@
G_SIGNAL_RUN_LAST,
offsetof (GtkSheetClass, select_column),
NULL, NULL,
- gtkextra_VOID__INT,
+ g_cclosure_marshal_VOID__INT,
G_TYPE_NONE,
1,
G_TYPE_INT);
@@ -947,7 +1008,7 @@
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
- gtkextra_VOID__INT,
+ g_cclosure_marshal_VOID__INT,
G_TYPE_NONE,
1,
G_TYPE_INT);
@@ -966,7 +1027,7 @@
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
- gtkextra_VOID__INT,
+ g_cclosure_marshal_VOID__INT,
G_TYPE_NONE,
1,
G_TYPE_INT);
@@ -1020,7 +1081,7 @@
G_SIGNAL_RUN_LAST,
offsetof (GtkSheetClass, select_range),
NULL, NULL,
- gtkextra_VOID__BOXED,
+ g_cclosure_marshal_VOID__BOXED,
G_TYPE_NONE,
1,
GTK_TYPE_SHEET_RANGE);
@@ -1067,8 +1128,8 @@
G_SIGNAL_RUN_LAST,
offsetof (GtkSheetClass, deactivate),
NULL, NULL,
- gtkextra_BOOLEAN__INT_INT,
- G_TYPE_BOOLEAN, 2, G_TYPE_INT, G_TYPE_INT);
+ gtkextra_VOID__INT_INT,
+ G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
sheet_signals[ACTIVATE] =
g_signal_new ("activate",
@@ -1079,25 +1140,6 @@
gtkextra_BOOLEAN__INT_INT,
G_TYPE_BOOLEAN, 2, G_TYPE_INT, G_TYPE_INT);
- sheet_signals[SET_CELL] =
- g_signal_new ("set-cell",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- offsetof (GtkSheetClass, set_cell),
- NULL, NULL,
- gtkextra_VOID__INT_INT,
- G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
-
-
- sheet_signals[CLEAR_CELL] =
- g_signal_new ("clear-cell",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- offsetof (GtkSheetClass, clear_cell),
- NULL, NULL,
- gtkextra_VOID__INT_INT,
- G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
-
sheet_signals[CHANGED] =
g_signal_new ("changed",
G_TYPE_FROM_CLASS (object_class),
@@ -1107,24 +1149,6 @@
gtkextra_VOID__INT_INT,
G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
- sheet_signals[NEW_COL_WIDTH] =
- g_signal_new ("new-column-width",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- offsetof (GtkSheetClass, new_column_width), /*!!!! */
- NULL, NULL,
- gtkextra_VOID__INT_INT,
- G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
-
- sheet_signals[NEW_ROW_HEIGHT] =
- g_signal_new ("new-row-height",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- offsetof (GtkSheetClass, new_row_height), /*!!!! */
- NULL, NULL,
- gtkextra_VOID__INT_INT,
- G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
-
widget_class->set_scroll_adjustments_signal =
g_signal_new ("set-scroll-adjustments",
G_TYPE_FROM_CLASS (object_class),
@@ -1139,8 +1163,44 @@
container_class->remove = gtk_sheet_remove;
container_class->forall = gtk_sheet_forall;
- object_class->destroy = gtk_sheet_destroy;
- gobject_class->finalize = gtk_sheet_finalize;
+ object_class->dispose = gtk_sheet_dispose;
+ object_class->finalize = gtk_sheet_finalize;
+
+
+ row_geo_spec =
+ g_param_spec_pointer ("row-geometry",
+ "Row Geometry",
+ "A pointer to the model of the row geometry",
+ G_PARAM_READABLE | G_PARAM_WRITABLE );
+
+ col_geo_spec =
+ g_param_spec_pointer ("column-geometry",
+ "Column Geometry",
+ "A pointer to the model of the column geometry",
+ G_PARAM_READABLE | G_PARAM_WRITABLE );
+
+ model_spec =
+ g_param_spec_pointer ("model",
+ "Model",
+ "A pointer to the data model",
+ G_PARAM_READABLE | G_PARAM_WRITABLE );
+
+
+ object_class->set_property = gtk_sheet_set_property;
+ object_class->get_property = gtk_sheet_get_property;
+
+ g_object_class_install_property (object_class,
+ PROP_ROW_GEO,
+ row_geo_spec);
+
+ g_object_class_install_property (object_class,
+ PROP_COL_GEO,
+ col_geo_spec);
+
+ g_object_class_install_property (object_class,
+ PROP_MODEL,
+ model_spec);
+
widget_class->realize = gtk_sheet_realize;
widget_class->unrealize = gtk_sheet_unrealize;
@@ -1166,8 +1226,6 @@
klass->traverse = NULL;
klass->deactivate = NULL;
klass->activate = NULL;
- klass->set_cell = NULL;
- klass->clear_cell = NULL;
klass->changed = NULL;
}
@@ -1241,6 +1299,24 @@
sheet->show_grid = TRUE;
sheet->motion_timer = 0;
+
+ sheet->columns_resizable = TRUE;
+ sheet->rows_resizable = TRUE;
+
+ sheet->row_titles_visible = TRUE;
+ sheet->row_title_area.width = DEFAULT_COLUMN_WIDTH;
+
+ sheet->column_titles_visible = TRUE;
+ sheet->autoscroll = TRUE;
+ sheet->justify_entry = TRUE;
+
+
+ /* create sheet entry */
+ sheet->entry_type = 0;
+ create_sheet_entry (sheet);
+
+ /* create global selection button */
+ create_global_button (sheet);
}
@@ -1364,12 +1440,6 @@
}
-static void gtk_sheet_construct (GtkSheet *sheet,
- GSheetRow *vgeo,
- GSheetColumn *hgeo,
- const gchar *title);
-
-
/**
* gtk_sheet_new:
* @rows: initial number of rows
@@ -1382,17 +1452,13 @@
* Returns: the new sheet widget
*/
GtkWidget *
-gtk_sheet_new (GSheetRow *vgeo, GSheetColumn *hgeo, const gchar *title,
- GSheetModel *model)
+gtk_sheet_new (GSheetRow *vgeo, GSheetColumn *hgeo, GSheetModel *model)
{
- GtkWidget *widget = g_object_new (GTK_TYPE_SHEET, NULL);
-
- gtk_sheet_construct (GTK_SHEET (widget), vgeo, hgeo, title);
-
- if (model)
- gtk_sheet_set_model (GTK_SHEET (widget), model);
-
-
+ GtkWidget *widget = g_object_new (GTK_TYPE_SHEET,
+ "row-geometry", vgeo,
+ "column-geometry", hgeo,
+ "model", model,
+ NULL);
return widget;
}
@@ -1409,10 +1475,13 @@
gtk_sheet_set_model (GtkSheet *sheet, GSheetModel *model)
{
g_return_if_fail (GTK_IS_SHEET (sheet));
- g_return_if_fail (G_IS_SHEET_MODEL (model));
+
+ if (sheet->model ) g_object_unref (sheet->model);
sheet->model = model;
+ if ( model)
+ {
g_signal_connect (model, "range_changed",
G_CALLBACK (range_update_callback), sheet);
@@ -1427,7 +1496,7 @@
g_signal_connect (model, "columns_deleted",
G_CALLBACK (columns_inserted_deleted_callback), sheet);
-
+ }
}
@@ -1463,73 +1532,6 @@
}
-static void
-gtk_sheet_construct (GtkSheet *sheet,
- GSheetRow *vgeo,
- GSheetColumn *hgeo,
- const gchar *title)
-{
- g_return_if_fail (G_IS_SHEET_COLUMN (hgeo));
- g_return_if_fail (G_IS_SHEET_ROW (vgeo));
-
- sheet->column_geometry = hgeo;
- sheet->row_geometry = vgeo;
-
-
- sheet->columns_resizable = TRUE;
- sheet->rows_resizable = TRUE;
-
- sheet->row_titles_visible = TRUE;
- sheet->row_title_area.width = DEFAULT_COLUMN_WIDTH;
-
- sheet->column_titles_visible = TRUE;
- sheet->autoscroll = TRUE;
- sheet->justify_entry = TRUE;
-
-
- /* create sheet entry */
- sheet->entry_type = 0;
- create_sheet_entry (sheet);
-
- /* create global selection button */
- create_global_button (sheet);
-
- if (title)
- sheet->name = g_strdup (title);
-
- g_signal_connect (sheet->column_geometry, "columns_changed",
- G_CALLBACK (column_titles_changed), sheet);
-
-}
-
-
-GtkWidget *
-gtk_sheet_new_with_custom_entry (GSheetRow *rows, GSheetColumn *columns,
- const gchar *title, GtkType entry_type)
-{
- GtkWidget *widget = g_object_new (GTK_TYPE_SHEET, NULL);
-
- gtk_sheet_construct_with_custom_entry (GTK_SHEET (widget),
- rows, columns, title, entry_type);
-
- return widget;
-}
-
-void
-gtk_sheet_construct_with_custom_entry (GtkSheet *sheet,
- GSheetRow *vgeo,
- GSheetColumn *hgeo,
- const gchar *title,
- GtkType entry_type)
-{
- gtk_sheet_construct (sheet, vgeo, hgeo, title);
-
- sheet->entry_type = entry_type;
- create_sheet_entry (sheet);
-}
-
-
-
void
gtk_sheet_change_entry (GtkSheet *sheet, GtkType entry_type)
{
@@ -1755,29 +1757,6 @@
}
-/* This routine has problems with gtk+- 1.2 related with the
- label / button drawing - I think it's a bug in gtk+- 1.2 */
-void
-gtk_sheet_set_title (GtkSheet *sheet, const gchar *title)
-{
- GtkWidget *label;
-
- g_return_if_fail (sheet != NULL);
- g_return_if_fail (title != NULL);
- g_return_if_fail (GTK_IS_SHEET (sheet));
-
- if (sheet->name)
- g_free (sheet->name);
-
- sheet->name = g_strdup (title);
-
- if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet)) || !title) return;
-
- if (GTK_BIN (sheet->button)->child)
- label = GTK_BIN (sheet->button)->child;
-
- size_allocate_global_button (sheet);
-}
void
gtk_sheet_freeze (GtkSheet *sheet)
@@ -2180,11 +2159,7 @@
if (sheet->state != GTK_SHEET_NORMAL)
gtk_sheet_real_unselect_range (sheet, NULL);
else
- {
- gboolean veto = TRUE;
- veto = gtk_sheet_deactivate_cell (sheet);
- if (!veto) return;
- }
+ gtk_sheet_deactivate_cell (sheet);
sheet->state = GTK_SHEET_ROW_SELECTED;
sheet->range.row0 = row;
@@ -2211,11 +2186,8 @@
if (sheet->state != GTK_SHEET_NORMAL)
gtk_sheet_real_unselect_range (sheet, NULL);
else
- {
- gboolean veto = TRUE;
- veto = gtk_sheet_deactivate_cell (sheet);
- if (!veto) return;
- }
+ gtk_sheet_deactivate_cell (sheet);
+
sheet->state = GTK_SHEET_COLUMN_SELECTED;
sheet->range.row0 = 0;
@@ -2424,26 +2396,24 @@
sheet = GTK_SHEET (object);
- if (sheet->name)
- {
- g_free (sheet->name);
- sheet->name = NULL;
- }
-
if (G_OBJECT_CLASS (parent_class)->finalize)
(*G_OBJECT_CLASS (parent_class)->finalize) (object);
}
static void
-gtk_sheet_destroy (GtkObject * object)
+gtk_sheet_dispose (GObject * object)
{
- GtkSheet *sheet;
+ GtkSheet *sheet = GTK_SHEET (object);
GList *children;
g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_SHEET (object));
- sheet = GTK_SHEET (object);
+ if ( sheet->dispose_has_run )
+ return ;
+
+ if (sheet->model) g_object_unref (sheet->model);
+ sheet->dispose_has_run = TRUE;
/* destroy the entry */
if (sheet->sheet_entry && GTK_IS_WIDGET (sheet->sheet_entry))
@@ -2452,12 +2422,7 @@
sheet->sheet_entry = NULL;
}
- /* destroy the global selection button */
- if (sheet->button && GTK_IS_WIDGET (sheet->button))
- {
- gtk_widget_destroy (sheet->button);
- sheet->button = NULL;
- }
+ g_object_unref (sheet->button);
/* unref adjustments */
if (sheet->hadjustment)
@@ -2493,8 +2458,8 @@
}
sheet->children = NULL;
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (*GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+ if (G_OBJECT_CLASS (parent_class)->dispose)
+ (*G_OBJECT_CLASS (parent_class)->dispose) (object);
}
static void
@@ -2526,7 +2491,6 @@
gint attributes_mask;
GdkGCValues values, auxvalues;
GdkColormap *colormap;
- gchar *name;
GtkSheetChild *child;
GList *children;
@@ -2645,11 +2609,6 @@
gtk_widget_set_parent_window (sheet->sheet_entry, sheet->sheet_window);
gtk_widget_set_parent (sheet->sheet_entry, GTK_WIDGET (sheet));
- if (sheet->button && sheet->button->parent)
- {
- gtk_widget_ref (sheet->button);
- gtk_widget_unparent (sheet->button);
- }
gtk_widget_set_parent_window (sheet->button, sheet->sheet_window);
gtk_widget_set_parent (sheet->button, GTK_WIDGET (sheet));
@@ -2664,11 +2623,6 @@
size_allocate_row_title_buttons (sheet);
size_allocate_column_title_buttons (sheet);
- name = g_strdup (sheet->name);
- gtk_sheet_set_title (sheet, name);
-
- g_free (name);
-
children = sheet->children;
while (children)
{
@@ -2686,6 +2640,8 @@
{
sheet->button = gtk_button_new_with_label (" ");
+ g_object_ref_sink (sheet->button);
+
g_signal_connect (sheet->button,
"pressed",
G_CALLBACK (global_button_clicked),
@@ -2761,15 +2717,13 @@
static void
gtk_sheet_map (GtkWidget * widget)
{
- GtkSheet *sheet;
+ GtkSheet *sheet = GTK_SHEET (widget);
GtkSheetChild *child;
GList *children;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_SHEET (widget));
- sheet = GTK_SHEET (widget);
-
if (!GTK_WIDGET_MAPPED (widget))
{
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
@@ -3487,10 +3441,6 @@
if (old_text && strlen (old_text) > 0 )
{
g_sheet_model_datum_clear (model, row, column);
-
- if (G_OBJECT (sheet)->ref_count > 0)
- g_signal_emit (sheet, sheet_signals[CLEAR_CELL], 0,
- row, column);
}
dispose_string (sheet, old_text);
@@ -3697,9 +3647,7 @@
return FALSE;
if (GTK_WIDGET_REALIZED (GTK_WIDGET (sheet)))
- {
- if (!gtk_sheet_deactivate_cell (sheet)) return FALSE;
- }
+ gtk_sheet_deactivate_cell (sheet);
sheet->active_cell.row = row;
sheet->active_cell.col = column;
@@ -3750,8 +3698,8 @@
if (row < 0 || col < 0) return;
- sheet->active_cell.row = -1;
- sheet->active_cell.col = -1;
+ sheet->active_cell.row =- 1;
+ sheet->active_cell.col =- 1;
text = gtk_entry_get_text (GTK_ENTRY (gtk_sheet_get_entry (sheet)));
@@ -3772,25 +3720,22 @@
}
-static gboolean
+static void
gtk_sheet_deactivate_cell (GtkSheet *sheet)
{
- gboolean veto = TRUE;
+ g_return_if_fail (sheet != NULL);
+ g_return_if_fail (GTK_IS_SHEET (sheet));
- g_return_val_if_fail (sheet != NULL, FALSE);
- g_return_val_if_fail (GTK_IS_SHEET (sheet), FALSE);
+ if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return ;
+ if (sheet->state != GTK_SHEET_NORMAL) return ;
- if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return FALSE;
- if (sheet->state != GTK_SHEET_NORMAL) return FALSE;
+ if ( sheet->active_cell.row == -1 || sheet->active_cell.col == -1 )
+ return ;
- _gtkextra_signal_emit (GTK_OBJECT (sheet), sheet_signals[DEACTIVATE],
+ g_signal_emit (sheet, sheet_signals[DEACTIVATE], 0,
sheet->active_cell.row,
- sheet->active_cell.col, &veto);
-
- if (!veto) return FALSE;
+ sheet->active_cell.col);
- if ( sheet->active_cell.row == -1 || sheet->active_cell.col == -1 )
- return TRUE;
g_signal_handlers_disconnect_by_func (gtk_sheet_get_entry (sheet),
G_CALLBACK (gtk_sheet_entry_changed),
@@ -3805,8 +3750,6 @@
GTK_SHEET_UNSET_FLAGS (sheet, GTK_SHEET_REDRAW_PENDING);
gtk_sheet_range_draw (sheet, NULL);
}
-
- return TRUE;
}
static void
@@ -4335,7 +4278,7 @@
gdk_gc_set_clip_rectangle (sheet->xor_gc, &area);
- for (i = -1; i <= 1; ++i)
+ for (i =- 1; i <= 1; ++i)
gdk_draw_rectangle (sheet->sheet_window,
sheet->xor_gc,
FALSE,
@@ -4518,11 +4461,7 @@
if (sheet->state != GTK_SHEET_NORMAL)
gtk_sheet_real_unselect_range (sheet, NULL);
else
- {
- gboolean veto = TRUE;
- veto = gtk_sheet_deactivate_cell (sheet);
- if (!veto) return;
- }
+ gtk_sheet_deactivate_cell (sheet);
sheet->range.row0 = range->row0;
sheet->range.rowi = range->rowi;
@@ -4784,7 +4723,7 @@
{
row = sheet->active_cell.row;
column = sheet->active_cell.col;
- if (!gtk_sheet_deactivate_cell (sheet)) return FALSE;
+ gtk_sheet_deactivate_cell (sheet);
sheet->active_cell.row = row;
sheet->active_cell.col = column;
sheet->drag_range = sheet->range;
@@ -4812,7 +4751,7 @@
{
row = sheet->active_cell.row;
column = sheet->active_cell.col;
- if (!gtk_sheet_deactivate_cell (sheet)) return FALSE;
+ gtk_sheet_deactivate_cell (sheet);
sheet->active_cell.row = row;
sheet->active_cell.col = column;
sheet->drag_range = sheet->range;
@@ -4916,7 +4855,7 @@
return;
}
- if (row == -1 && column == -1)
+ if (row == - 1 && column == - 1)
{
sheet->range.row0 = 0;
sheet->range.col0 = 0;
@@ -4937,11 +4876,7 @@
}
else
{
- if (!gtk_sheet_deactivate_cell (sheet))
- {
- *veto = FALSE;
- return;
- }
+ gtk_sheet_deactivate_cell (sheet);
gtk_sheet_activate_cell (sheet, row, column);
}
@@ -5529,8 +5464,8 @@
row_move = FALSE;
column_move = FALSE;
- row_align = -1.;
- col_align = -1.;
+ row_align =- 1.;
+ col_align =- 1.;
height = sheet->sheet_window_height;
width = sheet->sheet_window_width;
@@ -6080,6 +6015,8 @@
if (!GTK_WIDGET_DRAWABLE (sheet)) return;
+ size_allocate_global_button (sheet);
+
for (i = MIN_VISIBLE_COLUMN (sheet); i <= MAX_VISIBLE_COLUMN (sheet); i++)
gtk_sheet_column_title_button_draw (sheet, i);
}
@@ -6121,6 +6058,8 @@
if (!GTK_WIDGET_DRAWABLE (sheet)) return;
+ size_allocate_global_button (sheet);
+
for (i = MIN_VISIBLE_ROW (sheet); i <= MAX_VISIBLE_ROW (sheet); i++)
{
if ( i >= yyy_row_count (sheet))
@@ -7027,7 +6966,7 @@
gdk_gc_set_clip_rectangle (sheet->xor_gc, &clip_area);
- for (i = -1; i <= 1; ++i)
+ for (i =- 1; i <= 1; ++i)
gdk_draw_rectangle (sheet->sheet_window,
sheet->xor_gc,
FALSE,
@@ -7135,8 +7074,6 @@
}
g_signal_emit (sheet, sheet_signals[CHANGED], 0, -1, column);
- g_signal_emit (sheet, sheet_signals[NEW_COL_WIDTH], 0,
- column, width);
}
@@ -7168,12 +7105,7 @@
}
g_signal_emit (sheet, sheet_signals[CHANGED], 0, row, - 1);
- g_signal_emit (sheet, sheet_signals[NEW_ROW_HEIGHT], 0,
- row, height);
-
}
-
-
gboolean
gtk_sheet_get_attributes (const GtkSheet *sheet, gint row, gint col,
GtkSheetCellAttr *attributes)
Index: lib/gtksheet/gtksheet.h
===================================================================
RCS file: /sources/pspp/pspp/lib/gtksheet/gtksheet.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- lib/gtksheet/gtksheet.h 24 Jul 2007 13:05:05 -0000 1.16
+++ lib/gtksheet/gtksheet.h 20 Feb 2008 10:04:11 -0000 1.17
@@ -110,9 +110,12 @@
gint row, column;
};
-struct _GtkSheet{
+struct _GtkSheet
+{
GtkContainer container;
+
+ gboolean dispose_has_run;
GSheetColumn *column_geometry;
GSheetRow *row_geometry;
@@ -125,8 +128,6 @@
gboolean autoscroll;
gboolean justify_entry;
- guint freeze_count;
-
/* Background colors */
GdkColor bg_color;
GdkColor grid_color;
@@ -139,8 +140,6 @@
and the width of the shadow border */
GdkRectangle internal_allocation;
- gchar *name;
-
gint16 column_requisition;
gint16 row_requisition;
@@ -197,6 +196,8 @@
GtkAdjustment *hadjustment;
GtkAdjustment *vadjustment;
+ gint freeze_count;
+
/* xor GC for the verticle drag line */
GdkGC *xor_gc;
@@ -255,23 +256,8 @@
gboolean (*activate) (GtkSheet *sheet,
gint row, gint column);
- void (*set_cell) (GtkSheet *sheet,
- gint row, gint column);
-
- void (*clear_cell) (GtkSheet *sheet,
- gint row, gint column);
-
void (*changed) (GtkSheet *sheet,
gint row, gint column);
-
- void (*new_column_width) (GtkSheet *sheet,
- gint col,
- guint width);
-
- void (*new_row_height) (GtkSheet *sheet,
- gint row,
- guint height);
-
};
GType gtk_sheet_get_type (void);
@@ -280,7 +266,6 @@
/* create a new sheet */
GtkWidget * gtk_sheet_new (GSheetRow *vgeo, GSheetColumn *hgeo,
- const gchar *title,
GSheetModel *model);
@@ -298,13 +283,11 @@
GtkWidget *
gtk_sheet_new_with_custom_entry (GSheetRow *vgeo,
GSheetColumn *hgeo,
- const gchar *title,
GtkType entry_type);
void
gtk_sheet_construct_with_custom_entry (GtkSheet *sheet,
GSheetRow *vgeo,
GSheetColumn *hgeo,
- const gchar *title,
GtkType entry_type);
/* change scroll adjustments */
void
Index: src/ui/gui/data-sheet.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/data-sheet.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- src/ui/gui/data-sheet.c 8 Feb 2008 23:30:13 -0000 1.25
+++ src/ui/gui/data-sheet.c 20 Feb 2008 10:04:11 -0000 1.26
@@ -108,8 +108,7 @@
{
GtkWidget *sheet;
- sheet = gtk_sheet_new (G_SHEET_ROW (the_data_store),
- G_SHEET_COLUMN (the_data_store), "data sheet", 0);
+ sheet = gtk_sheet_new (G_SHEET_ROW (the_data_store), G_SHEET_COLUMN
(the_data_store), NULL);
the_data_store->width_of_m = calc_m_width (sheet, the_data_store->font_desc);
Index: src/ui/gui/var-sheet.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/var-sheet.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- src/ui/gui/var-sheet.c 15 Sep 2007 02:48:03 -0000 1.26
+++ src/ui/gui/var-sheet.c 20 Feb 2008 10:04:11 -0000 1.27
@@ -90,6 +90,13 @@
0
};
+G_DEFINE_TYPE (PsppireVarSheet, psppire_var_sheet, GTK_TYPE_SHEET);
+
+static void
+psppire_var_sheet_class_init (PsppireVarSheetClass *class)
+{
+}
+
static GtkListStore *
create_label_list (const gchar *const *labels)
{
@@ -150,10 +157,14 @@
gint *new_row, gint *new_column
)
{
+ PsppireVarSheet *var_sheet = PSPPIRE_VAR_SHEET (sheet);
PsppireVarStore *var_store = PSPPIRE_VAR_STORE (gtk_sheet_get_model (sheet));
gint n_vars = psppire_var_store_get_var_cnt (var_store);
+ if (*new_row >= n_vars && !var_sheet->may_create_vars)
+ return FALSE;
+
if ( row == n_vars && *new_row >= n_vars)
{
GtkEntry *entry = GTK_ENTRY (gtk_sheet_get_entry (sheet));
@@ -415,58 +426,73 @@
return TRUE;
}
+static void
+psppire_var_sheet_init (PsppireVarSheet *self)
+{
+ self->may_create_vars = true;
-extern PsppireVarStore *the_var_store;
+ g_signal_connect (self, "activate",
+ GTK_SIGNAL_FUNC (var_sheet_cell_entry_enter),
+ 0);
+ g_signal_connect (self, "deactivate",
+ GTK_SIGNAL_FUNC (var_sheet_cell_entry_leave),
+ 0);
-/* Create the var sheet */
-G_MODULE_EXPORT GtkWidget*
-psppire_variable_sheet_create (gchar *widget_name,
- gchar *string1,
- gchar *string2,
- gint int1, gint int2)
+ g_signal_connect (self, "traverse",
+ GTK_SIGNAL_FUNC (traverse_cell_callback), 0);
+}
+
+GtkWidget *
+psppire_var_sheet_new_with_var_store (PsppireVarStore *var_store)
{
- gchar *codeset;
- gint i;
GtkWidget *sheet;
+ gint i;
+
GObject *geo = g_sheet_hetero_column_new (75, n_COLS);
+ g_assert (var_store);
- g_assert (the_var_store);
+ sheet = g_object_new (PSPPIRE_TYPE_VAR_SHEET,
+ "row-geometry", var_store,
+ "column-geometry", geo,
+ NULL);
- sheet = gtk_sheet_new (G_SHEET_ROW (the_var_store),
- G_SHEET_COLUMN (geo),
- "variable sheet", 0);
+ gtk_sheet_set_model (GTK_SHEET (sheet), G_SHEET_MODEL (var_store));
- g_signal_connect (GTK_OBJECT (sheet), "activate",
- GTK_SIGNAL_FUNC (var_sheet_cell_entry_enter),
- 0);
+ for (i = 0 ; i < n_COLS ; ++i )
+ {
+ g_sheet_hetero_column_set_button_label (G_SHEET_HETERO_COLUMN (geo), i,
+ gettext (column_def[i].label));
- g_signal_connect (GTK_OBJECT (sheet), "deactivate",
- GTK_SIGNAL_FUNC (var_sheet_cell_entry_leave),
- 0);
+ g_sheet_hetero_column_set_width (G_SHEET_HETERO_COLUMN (geo), i,
+ column_def[i].width);
+ }
- g_signal_connect (GTK_OBJECT (sheet), "traverse",
- GTK_SIGNAL_FUNC (traverse_cell_callback), 0);
- gtk_sheet_set_model (GTK_SHEET (sheet), G_SHEET_MODEL (the_var_store));
+ return sheet;
+}
+/* Create the var sheet */
+G_MODULE_EXPORT GtkWidget*
+psppire_variable_sheet_create (gchar *widget_name,
+ gchar *string1,
+ gchar *string2,
+ gint int1, gint int2)
+{
+ gchar *codeset;
+ GtkWidget *sheet;
+ extern PsppireVarStore *the_var_store;
/* Since this happens inside glade_xml_new, we must prevent strings from
* being re-encoded twice */
codeset = xstrdup (bind_textdomain_codeset (PACKAGE, 0));
bind_textdomain_codeset (PACKAGE, locale_charset ());
- for (i = 0 ; i < n_COLS ; ++i )
- {
- g_sheet_hetero_column_set_button_label (G_SHEET_HETERO_COLUMN (geo), i,
- gettext (column_def[i].label));
- g_sheet_hetero_column_set_width (G_SHEET_HETERO_COLUMN (geo), i,
- column_def[i].width);
- }
+ sheet = psppire_var_sheet_new_with_var_store (the_var_store);
bind_textdomain_codeset (PACKAGE, codeset);
free (codeset);
@@ -477,3 +503,10 @@
}
+
+void
+psppire_var_sheet_set_may_create_vars (PsppireVarSheet *sheet,
+ gboolean may_create_vars)
+{
+ sheet->may_create_vars = may_create_vars;
+}
Index: src/ui/gui/var-sheet.h
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/var-sheet.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- src/ui/gui/var-sheet.h 7 Jul 2007 06:14:30 -0000 1.8
+++ src/ui/gui/var-sheet.h 20 Feb 2008 10:04:11 -0000 1.9
@@ -21,6 +21,17 @@
#include <gtksheet/gtksheet.h>
#include "psppire-dict.h"
+#include "psppire-var-store.h"
+
+#define PSPPIRE_TYPE_VAR_SHEET (psppire_var_sheet_get_type ())
+#define PSPPIRE_VAR_SHEET(obj) (G_TYPE_CHECK_INSTANCE_CAST
((obj), PSPPIRE_TYPE_VAR_SHEET, PsppireVarSheet))
+#define PSPPIRE_VAR_SHEET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST
((klass), PSPPIRE_TYPE_VAR_SHEET, PsppireVarSheetClass))
+#define PSPPIRE_IS_VAR_SHEET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
PSPPIRE_TYPE_VAR_SHEET))
+#define PSPPIRE_IS_VAR_SHEET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
PSPPIRE_TYPE_VAR_SHEET))
+#define PSPPIRE_VAR_SHEET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
PSPPIRE_TYPE_VAR_SHEET, PsppireVarSheetClass))
+
+typedef struct _PsppireVarSheet PsppireVarSheet;
+typedef struct _PsppireVarSheetClass PsppireVarSheetClass;
enum {COL_NAME,
COL_TYPE,
@@ -34,18 +45,34 @@
COL_MEASURE,
n_COLS};
+struct _PsppireVarSheet {
+ GtkSheet parent;
+ gboolean may_create_vars;
+};
+
+struct _PsppireVarSheetClass {
+ GtkSheetClass parent;
+};
-void var_sheet_range_set_editable (GtkSheet *sheet,
- const GtkSheetRange *urange,
- gboolean editable);
-
+GType psppire_var_sheet_get_type (void);
/* Create the var sheet */
+GtkWidget* psppire_var_sheet_new_with_var_store (PsppireVarStore *);
+
+/* Glade interface for creating a var sheet. */
GtkWidget* psppire_variable_sheet_create (gchar *widget_name,
gchar *string1,
gchar *string2,
gint int1, gint int2);
+void psppire_var_sheet_range_set_editable (PsppireVarSheet *sheet,
+ const GtkSheetRange *urange,
+ gboolean editable);
+
+void psppire_var_sheet_set_may_create_vars (PsppireVarSheet *sheet,
+ gboolean may_create_vars);
+
+
#define n_ALIGNMENTS 3
extern const gchar *const alignments[n_ALIGNMENTS + 1];