+++ /dev/null
-/* gtkextra
- * Copyright 1999-2001 Adrian E. Feiguin <feiguin@ifir.edu.ar>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-
-#include <string.h>
-#include <gtk/gtk.h>
-#include "gtkextrafeatures.h"
-#include <gobject/gvaluecollector.h>
-
-const guint gtkextra_major_version = GTKEXTRA_MAJOR_VERSION;
-const guint gtkextra_minor_version = GTKEXTRA_MINOR_VERSION;
-const guint gtkextra_micro_version = GTKEXTRA_MICRO_VERSION;
-const guint gtkextra_binary_age = GTKEXTRA_BINARY_AGE;
-const guint gtkextra_interface_age = GTKEXTRA_INTERFACE_AGE;
-
-gchar *
-gtkextra_check_version (guint required_major,
- guint required_minor,
- guint required_micro)
-{
- if (required_major > GTKEXTRA_MAJOR_VERSION)
- return "GtkExtra version too old (major mismatch)";
- if (required_major < GTKEXTRA_MAJOR_VERSION)
- return "GtkExtra version too new (major mismatch)";
- if (required_minor > GTKEXTRA_MINOR_VERSION)
- return "GtkExtra version too old (minor mismatch)";
- if (required_minor < GTKEXTRA_MINOR_VERSION)
- return "GtkExtra version too new (minor mismatch)";
- if (required_micro < GTKEXTRA_MICRO_VERSION - GTKEXTRA_BINARY_AGE)
- return "GtkExtra version too new (micro mismatch)";
- if (required_micro > GTKEXTRA_MICRO_VERSION)
- return "GtkExtra version too old (micro mismatch)";
- return NULL;
-}
-
-/*
-void
-_gtkextra_signal_test(GtkObject *object, guint signal_id, gint arg1, gint arg2, gboolean *default_ret)
-{
- gboolean result;
- GValue ret = { 0, };
- GValue instance_and_param[3] = { { 0, }, {0, }, {0, } };
-
- g_value_init(instance_and_param + 0, GTK_OBJECT_TYPE(object));
- g_value_set_instance(instance_and_param + 0, G_OBJECT(object));
-
- g_value_init(instance_and_param + 1, G_TYPE_INT);
- g_value_set_int(instance_and_param + 1, arg1);
-
- g_value_init(instance_and_param + 2, G_TYPE_INT);
- g_value_set_int(instance_and_param + 2, arg2);
-
- g_value_init(&ret, G_TYPE_BOOLEAN);
- g_value_set_boolean(&ret, *default_ret);
-
- g_signal_emitv(instance_and_param, signal_id, 0, &ret);
- *default_ret = g_value_get_boolean(&ret);
-
- g_value_unset(instance_and_param + 0);
- g_value_unset(instance_and_param + 1);
- g_value_unset(instance_and_param + 2);
-}
-*/
-
-void
-_gtkextra_signal_emit(GtkObject *object, guint signal_id, ...)
-{
- gboolean *result;
- GValue ret = { 0, };
- GValue instance_and_params [10] = { {0, }, };
- va_list var_args;
- GSignalQuery query;
- gchar *error;
- int i;
-
- va_start (var_args, signal_id);
-
- g_value_init(instance_and_params + 0, GTK_OBJECT_TYPE(object));
- g_value_set_instance (instance_and_params + 0, G_OBJECT(object));
-
- g_signal_query(signal_id, &query);
-
- for (i = 0; i < query.n_params; i++)
- {
- gboolean static_scope = query.param_types[i]&~G_SIGNAL_TYPE_STATIC_SCOPE;
- g_value_init(instance_and_params + i + 1, query.param_types[i]);
-
-
- G_VALUE_COLLECT (instance_and_params + i + 1,
- var_args,
- static_scope ? G_VALUE_NOCOPY_CONTENTS : 0,
- &error);
-
- if (error)
- {
- g_warning ("%s: %s", G_STRLOC, error);
- g_free (error);
- while (i-- > 0)
- g_value_unset (instance_and_params + i);
-
- va_end (var_args);
- return;
- }
-
-
- }
-
- g_value_init(&ret, query.return_type);
- result = va_arg(var_args,gboolean *);
- g_value_set_boolean(&ret, *result);
- g_signal_emitv(instance_and_params, signal_id, 0, &ret);
- *result = g_value_get_boolean(&ret);
- g_value_unset (&ret);
-
- for (i = 0; i < query.n_params; i++)
- g_value_unset (instance_and_params + 1 + i);
- g_value_unset (instance_and_params + 0);
-
- va_end (var_args);
-}
gint row, gint col);
static void gtk_sheet_draw_active_cell (GtkSheet *sheet);
static void gtk_sheet_show_active_cell (GtkSheet *sheet);
-static void gtk_sheet_click_cell (GtkSheet *sheet,
+static gboolean gtk_sheet_click_cell (GtkSheet *sheet,
gint row,
- gint column,
- gboolean *veto);
+ gint column);
/* Backing Pixmap */
-
static void gtk_sheet_make_backing_pixmap (GtkSheet *sheet);
static void gtk_sheet_draw_backing_pixmap (GtkSheet *sheet,
/* Signals */
-
-extern void
-_gtkextra_signal_emit (GtkObject *object, guint signal_id, ...);
-
enum
{
SELECT_ROW,
sheet->row_title_area.width = DEFAULT_COLUMN_WIDTH;
sheet->column_titles_visible = TRUE;
- sheet->autoscroll = TRUE;
- sheet->justify_entry = TRUE;
/* create sheet entry */
}
-void
-gtk_sheet_set_autoscroll (GtkSheet *sheet, gboolean autoscroll)
-{
- g_return_if_fail (sheet != NULL);
- g_return_if_fail (GTK_IS_SHEET (sheet));
-
- sheet->autoscroll = autoscroll;
-}
-
-gboolean
-gtk_sheet_autoscroll (GtkSheet *sheet)
-{
- g_return_val_if_fail (sheet != NULL, FALSE);
- g_return_val_if_fail (GTK_IS_SHEET (sheet), FALSE);
-
- return sheet->autoscroll;
-}
-
-
-void
-gtk_sheet_set_justify_entry (GtkSheet *sheet, gboolean justify)
-{
- g_return_if_fail (sheet != NULL);
- g_return_if_fail (GTK_IS_SHEET (sheet));
-
- sheet->justify_entry = justify;
-}
-
-gboolean
-gtk_sheet_justify_entry (GtkSheet *sheet)
-{
- g_return_val_if_fail (sheet != NULL, FALSE);
- g_return_val_if_fail (GTK_IS_SHEET (sheet), FALSE);
-
- return sheet->justify_entry;
-}
-
void
gtk_sheet_set_row_titles_width (GtkSheet *sheet, guint width)
static void
global_button_clicked (GtkWidget *widget, gpointer data)
{
- gboolean veto;
-
- gtk_sheet_click_cell (GTK_SHEET (data), - 1, - 1, &veto);
+ gtk_sheet_click_cell (GTK_SHEET (data), -1, -1);
gtk_widget_grab_focus (GTK_WIDGET (data));
}
if (!gtk_sheet_activate_cell (sheet, row, column)) return FALSE;
- if (gtk_sheet_autoscroll (sheet))
- gtk_sheet_move_query (sheet, row, column);
return TRUE;
}
G_CALLBACK (gtk_sheet_entry_changed),
sheet);
- _gtkextra_signal_emit (GTK_OBJECT (sheet), sheet_signals [ACTIVATE], row, col, &veto);
+ g_signal_emit (sheet, sheet_signals [ACTIVATE], 0, row, col, &veto);
return TRUE;
}
justification = GTK_JUSTIFY_LEFT;
- if (gtk_sheet_justify_entry (sheet))
- justification = attributes.justification;
text = gtk_sheet_cell_get_text (sheet, row, col);
if ( ! text )
}
else
{
- gtk_sheet_click_cell (sheet, row, column, &veto);
+ veto = gtk_sheet_click_cell (sheet, row, column);
if (veto) GTK_SHEET_SET_FLAGS (sheet, GTK_SHEET_IN_SELECTION);
}
}
if (g_sheet_column_get_sensitivity (sheet->column_geometry, column))
{
- gtk_sheet_click_cell (sheet, - 1, column, &veto);
+ veto = gtk_sheet_click_cell (sheet, -1, column);
gtk_grab_add (GTK_WIDGET (sheet));
gtk_widget_grab_focus (GTK_WIDGET (sheet));
GTK_SHEET_SET_FLAGS (sheet, GTK_SHEET_IN_SELECTION);
row = yyy_row_ypixel_to_row (sheet, y);
if (g_sheet_row_get_sensitivity (sheet->row_geometry, row))
{
- gtk_sheet_click_cell (sheet, row, - 1, &veto);
+ veto = gtk_sheet_click_cell (sheet, row, -1);
gtk_grab_add (GTK_WIDGET (sheet));
gtk_widget_grab_focus (GTK_WIDGET (sheet));
GTK_SHEET_SET_FLAGS (sheet, GTK_SHEET_IN_SELECTION);
return TRUE;
}
-static void
-gtk_sheet_click_cell (GtkSheet *sheet, gint row, gint column, gboolean *veto)
+static gboolean
+gtk_sheet_click_cell (GtkSheet *sheet, gint row, gint column)
{
- *veto = TRUE;
+ gboolean forbid_move;
- if (row >= g_sheet_row_get_row_count (sheet->row_geometry) || column >= g_sheet_column_get_column_count (sheet->column_geometry))
+ if (row >= g_sheet_row_get_row_count (sheet->row_geometry)
+ || column >= g_sheet_column_get_column_count (sheet->column_geometry))
{
- *veto = FALSE;
- return;
+ return FALSE;
}
if (column >= 0 && row >= 0)
if (! g_sheet_column_get_visibility (sheet->column_geometry, column)
|| !g_sheet_row_get_visibility (sheet->row_geometry, row))
{
- *veto = FALSE;
- return;
+ return FALSE;
}
}
- _gtkextra_signal_emit (GTK_OBJECT (sheet), sheet_signals[TRAVERSE],
- sheet->active_cell.row, sheet->active_cell.col,
- &row, &column, veto);
+ g_signal_emit (sheet, sheet_signals[TRAVERSE], 0,
+ sheet->active_cell.row, sheet->active_cell.col,
+ &row, &column, &forbid_move);
- if (!*veto)
+ if (forbid_move)
{
- if (sheet->state == GTK_STATE_NORMAL) return;
+ if (sheet->state == GTK_STATE_NORMAL)
+ return FALSE;
row = sheet->active_cell.row;
column = sheet->active_cell.col;
gtk_sheet_activate_cell (sheet, row, column);
- return;
+ return FALSE;
}
if (row == -1 && column >= 0)
{
- if (gtk_sheet_autoscroll (sheet))
- gtk_sheet_move_query (sheet, row, column);
gtk_sheet_select_column (sheet, column);
- return;
+ return TRUE;
}
+
if (column == -1 && row >= 0)
{
- if (gtk_sheet_autoscroll (sheet))
- gtk_sheet_move_query (sheet, row, column);
gtk_sheet_select_row (sheet, row);
- return;
+ return TRUE;
}
if (row == - 1 && column == - 1)
sheet->range.row0 = 0;
sheet->range.col0 = 0;
sheet->range.rowi = g_sheet_row_get_row_count (sheet->row_geometry) - 1;
- sheet->range.coli = g_sheet_column_get_column_count (sheet->column_geometry) - 1;
+ sheet->range.coli =
+ g_sheet_column_get_column_count (sheet->column_geometry) - 1;
sheet->active_cell.row = 0;
sheet->active_cell.col = 0;
gtk_sheet_select_range (sheet, NULL);
- return;
+ return TRUE;
}
if (row != -1 && column != -1)
gtk_sheet_activate_cell (sheet, row, column);
}
- if (gtk_sheet_autoscroll (sheet))
- gtk_sheet_move_query (sheet, row, column);
sheet->active_cell.row = row;
sheet->active_cell.col = column;
sheet->selection_cell.row = row;
sheet->state = GTK_SHEET_NORMAL;
GTK_SHEET_SET_FLAGS (sheet, GTK_SHEET_IN_SELECTION);
gtk_sheet_draw_active_cell (sheet);
- return;
+ return TRUE;
}
g_assert_not_reached ();
- gtk_sheet_activate_cell (sheet, sheet->active_cell.row,
- sheet->active_cell.col);
}
static gint
}
+static void
+step_horizontal (GtkSheet *sheet, GtkScrollType dir)
+{
+ switch ( dir)
+ {
+ case GTK_SCROLL_STEP_RIGHT:
+
+ gtk_sheet_activate_cell (sheet,
+ sheet->active_cell.row,
+ sheet->active_cell.col + 1);
+ break;
+ case GTK_SCROLL_STEP_LEFT:
+
+ gtk_sheet_activate_cell (sheet,
+ sheet->active_cell.row,
+ sheet->active_cell.col - 1);
+ break;
+
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ if ( sheet->active_cell.col >= max_visible_column (sheet))
+ {
+ glong hpos =
+ g_sheet_column_start_pixel (sheet->column_geometry,
+ sheet->active_cell.col + 1);
+ hpos -= sheet->hadjustment->page_size;
+
+ gtk_adjustment_set_value (sheet->hadjustment,
+ hpos);
+ }
+ else if ( sheet->active_cell.col <= min_visible_column (sheet))
+ {
+ glong hpos =
+ g_sheet_column_start_pixel (sheet->column_geometry,
+ sheet->active_cell.col);
+
+ gtk_adjustment_set_value (sheet->hadjustment,
+ hpos);
+ }
+}
+
static gboolean
gtk_sheet_key_press (GtkWidget *widget,
GdkEventKey *key)
switch (key->keyval)
{
+ case GDK_Tab:
case GDK_Right:
- gtk_sheet_activate_cell (sheet,
- sheet->active_cell.row,
- sheet->active_cell.col + 1);
-
- if ( sheet->active_cell.col >= max_visible_column (sheet))
- {
- glong hpos =
- g_sheet_column_start_pixel (sheet->column_geometry,
- sheet->active_cell.col + 1);
- hpos -= sheet->hadjustment->page_size;
-
- gtk_adjustment_set_value (sheet->hadjustment,
- hpos);
- }
+ step_horizontal (sheet, GTK_SCROLL_STEP_RIGHT);
break;
+ case GDK_ISO_Left_Tab:
case GDK_Left:
- gtk_sheet_activate_cell (sheet,
- sheet->active_cell.row,
- sheet->active_cell.col - 1);
-
- if ( sheet->active_cell.col <= min_visible_column (sheet))
- {
- glong hpos =
- g_sheet_column_start_pixel (sheet->column_geometry,
- sheet->active_cell.col);
-
- gtk_adjustment_set_value (sheet->hadjustment,
- hpos);
- }
-
+ step_horizontal (sheet, GTK_SCROLL_STEP_LEFT);
break;
+ case GDK_Return:
case GDK_Down:
gtk_sheet_activate_cell (sheet,
sheet->active_cell.row + ROWS_PER_STEP,
*/
break;
- case GDK_Tab:
- break;
- case GDK_Return:
- g_print ("Enter\n");
- break;
-
default:
return FALSE;
break;