Closed songqingshan closed 5 years ago
Which branch are you using?
Hello,
Thanks for your reply. Since I post it for a quite while and I have not got any response, I can not remember which branch now. Do you know how many branches? I remember I posted multiple issues in two branches.
From: Fredy Paquet notifications@github.com Sent: March 3, 2019 11:24 AM To: fpaquet/gtksheet Cc: songqingshan; Author Subject: Re: [fpaquet/gtksheet] gtksheet crashes (#10)
Which branch are you using?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/fpaquet/gtksheet/issues/10#issuecomment-469044179, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ApTBU3-ssC-amWDYL8IZryMkBTz11IMHks5vTAVDgaJpZM4ZdUr8.
Sorry for the late reply, issue notifications are not yet configured properly.
The current "gtk3" branch could produce these crashes. Since last Gtk3 release, I made a lot of Bugfixes in the "gtk3_fixes" branch which should solve the crash and missing buttons.
I'm planning to publish a bugfix release by next weekend.
The timer issue is new to me.
Hello Fredy,
Thanks for your response. I believe that the issues are caused by gtk component (e.g., gtkbuttons) mapping. Some did not map which causes ID cannot be found. I made some changes in the gtksheet. Some of issues(like buttons disappear after turning page) are solved , but row title button or the top-left button still exists mapping issue which is not solved yet. Currently I do not have time to make commit for this issue. If you like to know what changes that I made, I can send your gtksheet in which you can find my notes. Thank you again. Song
From: Fredy Paquet notifications@github.com Sent: March 4, 2019 12:36 AM To: fpaquet/gtksheet Cc: songqingshan; Author Subject: Re: [fpaquet/gtksheet] gtksheet crashes (#10)
Sorry for the late reply, issue notifications are not yet configured properly.
The current "gtk3" branch could produce these crashes. Since last Gtk3 release, I made a lot of Bugfixes in the "gtk3_fixes" branch which should solve the crash and missing buttons.
I'm planning to publish a bugfix release by next weekend.
The timer issue is new to me.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/fpaquet/gtksheet/issues/10#issuecomment-469135664, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ApTBUw9mf7iA0CI2E8tL5pGXI10Kn2jjks5vTL8LgaJpZM4ZdUr8.
I've now released V4.3.0 for Gtk3 (branch gtk3) https://github.com/fpaquet/gtksheet/releases/tag/V4.3.0
And published online docs V4 https://fpaquet.github.io/gtksheet/reference/index.html
This should fix the crash issue.
Hello Fredy Paquet,
Thanks for your informing me. That is great! I will try it once I have time. I had found a few more programs which are not submitted a quite while ago . After I try your new version, I will submit them if they still exist. Thank you for your work. I believe that you solve mapping problems.
Song
From: Fredy Paquet notifications@github.com Sent: March 9, 2019 5:37 AM To: fpaquet/gtksheet Cc: songqingshan; Author Subject: Re: [fpaquet/gtksheet] gtksheet crashes (#10)
I've now released V4.3.0 for Gtk3 (branch gtk3) https://github.com/fpaquet/gtksheet/releases/tag/V4.3.0
And published online docs V4 https://fpaquet.github.io/gtksheet/reference/index.html
This should fix the crash issue.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/fpaquet/gtksheet/issues/10#issuecomment-471169673, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ApTBUxuwqHSiVBt7ZpmCu1U0iR9fvQTBks5vU5zhgaJpZM4ZdUr8.
The timer issue was fixed in commit 6620015 in branch gtk3_fixes Thank you for reporting.
Hello Fredy, According to my experience, this issue is highly possible related to the button "0" mapping. When I delete all cells in the sheet, button "0" still is here. After a while, the button "0" is gone by clicking somewhere on the sheet. Song
Hi Fredy, Attached is the gtksheet that I made some changes which solves the part of mapping issues. You just need to type "shan", then you can find notes and changes that I made. I hope it is useful for you.
Song
From: Fredy Paquet notifications@github.com Sent: March 9, 2019 5:37 AM To: fpaquet/gtksheet Cc: songqingshan; Author Subject: Re: [fpaquet/gtksheet] gtksheet crashes (#10)
I've now released V4.3.0 for Gtk3 (branch gtk3) https://github.com/fpaquet/gtksheet/releases/tag/V4.3.0
And published online docs V4 https://fpaquet.github.io/gtksheet/reference/index.html
This should fix the crash issue.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/fpaquet/gtksheet/issues/10#issuecomment-471169673, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ApTBUxuwqHSiVBt7ZpmCu1U0iR9fvQTBks5vU5zhgaJpZM4ZdUr8.
/* GtkSheet widget for Gtk+.
/**
static GdkCursorType gdk_cursor_get_cursor_type (GdkCursor *cursor) { g_return_val_if_fail (cursor != NULL, GDK_BLANK_CURSOR); return cursor->type; }
/ sheet flags / enum _GtkSheetFlags { GTK_SHEET_IS_LOCKED = 1 << 0, / sheet is not editable / GTK_SHEET_IS_FROZEN = 1 << 1, / frontend updates temporarily disabled / GTK_SHEET_IN_XDRAG = 1 << 2, / column being resized / GTK_SHEET_IN_YDRAG = 1 << 3, / row being resized / GTK_SHEET_IN_DRAG = 1 << 4, / cell selection being moved / GTK_SHEET_IN_SELECTION = 1 << 5, / cell selection being created / GTK_SHEET_IN_RESIZE = 1 << 6, / cell selection being resized / GTK_SHEET_IN_CLIP = 1 << 7, / cell selection in clipboard / GTK_SHEET_IN_REDRAW_PENDING = 1 << 8, / redraw on deactivate / GTK_SHEET_IN_AUTORESIZE_PENDING = 1 << 9, / autoresize pending / GTK_SHEET_IS_DESTROYED = 1 << 10, / set by destruct handler / };
enum _GtkSheetProperties { PROP_GTK_SHEET_0, / dummy / PROP_GTK_SHEET_TITLE, / gtk_sheet_set_title() / PROP_GTK_SHEET_DESCRIPTION, / gtk_sheet_set_description() / PROP_GTK_SHEET_NCOLS, / number of colunms - necessary for glade object creation / PROP_GTK_SHEET_NROWS, / number of rows - necessary for glade object creation / PROP_GTK_SHEET_LOCKED, / gtk_sheet_set_locked() / PROP_GTK_SHEET_SELECTION_MODE, / gtk_sheet_set_selection_mode() / PROP_GTK_SHEET_AUTO_RESIZE, / gtk_sheet_set_autoresize() / PROP_GTK_SHEET_AUTO_RESIZE_ROWS, / gtk_sheet_set_autoresize_rows() / PROP_GTK_SHEET_AUTO_RESIZE_COLUMNS, / gtk_sheet_set_autoresize_columns() / PROP_GTK_SHEET_AUTO_SCROLL, / gtk_sheet_set_autoscroll() / PROP_GTK_SHEET_CLIP_TEXT, / gtk_sheet_set_clip_text() / PROP_GTK_SHEET_JUSTIFY_ENTRY, / gtk_sheet_set_justify_entry() / PROP_GTK_SHEET_BG_COLOR, / gtk_sheet_set_background() / PROP_GTK_SHEET_GRID_VISIBLE, / gtk_sheet_show_grid() / PROP_GTK_SHEET_GRID_COLOR, / gtk_sheet_set_grid() / PROP_GTK_SHEET_COLUMN_TITLES_VISIBLE, / gtk_sheet_show_column_titles() / PROP_GTK_SHEET_COLUMNS_RESIZABLE, / gtk_sheet_columns_set_resizable() / PROP_GTK_SHEET_COLUMN_TITLES_HEIGHT, / gtk_sheet_set_column_titles_height() / PROP_GTK_SHEET_ROW_TITLES_VISIBLE, / gtk_sheet_show_row_titles() / PROP_GTK_SHEET_ROWS_RESIZABLE, / gtk_sheet_rows_set_resizable() / PROP_GTK_SHEET_ROW_TITLES_WIDTH, / gtk_sheet_set_row_titles_width() / PROP_GTK_SHEET_ENTRY_TYPE, / gtk_sheet_change_entry() / PROP_GTK_SHEET_VJUST, / gtk_sheet_set_vjustification() / PROP_GTK_SHEET_HADJUSTMENT, / gtk_sheet_set_hadjustment() / PROP_GTK_SHEET_VADJUSTMENT, / gtk_sheet_set_vadjustment() / PROP_GTK_SHEET_HSCROLL_POLICY, / GtkScrollable interface / PROP_GTK_SHEET_VSCROLL_POLICY, / GtkScrollable interface / };
/ Signals /
enum _GtkSheetSignals { SELECT_ROW, SELECT_COLUMN, SELECT_RANGE, CLIP_RANGE, RESIZE_RANGE, MOVE_RANGE, TRAVERSE, DEACTIVATE, ACTIVATE, SET_CELL, CLEAR_CELL, CHANGED, NEW_COL_WIDTH, NEW_ROW_HEIGHT, ENTRY_FOCUS_IN, ENTRY_FOCUS_OUT, ENTRY_POPULATE_POPUP, MOVE_CURSOR, ENTER_PRESSED, LAST_SIGNAL }; static guint sheet_signals[LAST_SIGNAL] = { 0 };
typedef enum _GtkSheetArea { ON_SHEET_BUTTON_AREA, ON_ROW_TITLES_AREA, ON_COLUMN_TITLES_AREA, ON_CELL_AREA } GtkSheetArea;
(GTK_SHEET (sheet)->flags)
(GTK_SHEET_FLAGS (sheet) |= (flag))
(GTK_SHEET_FLAGS (sheet) &= ~(flag))
(GTK_SHEET_FLAGS (sheet) & GTK_SHEET_IS_FROZEN)
(GTK_SHEET_FLAGS (sheet) & GTK_SHEET_IN_XDRAG)
(GTK_SHEET_FLAGS (sheet) & GTK_SHEET_IN_YDRAG)
(GTK_SHEET_FLAGS (sheet) & GTK_SHEET_IN_DRAG)
(GTK_SHEET_FLAGS (sheet) & GTK_SHEET_IN_SELECTION)
(GTK_SHEET_FLAGS (sheet) & GTK_SHEET_IN_RESIZE)
(GTK_SHEET_FLAGS (sheet) & GTK_SHEET_IN_CLIP)
(GTK_SHEET_FLAGS (sheet) & GTK_SHEET_IN_REDRAW_PENDING)
/ data access macros - no frontend update! /
(sheet->view.row0)
/ beware: MAX_VISIBLE_ROW() can be maxrow+1 /
(sheet->view.rowi)
(sheet->view.col0)
/ beware: MAX_VISIBLE_COLUMN() can be maxcol+1 /
(sheet->view.coli)
/ widget flag tests and settings /
((rowptr)->is_visible)
((rowptr)->is_visible = (value))
((rowptr)->is_sensitive)
((rowptr)->is_sensitive = (value))
GTK_SHEET_ROW_IS_SENSITIVE(rowptr)
/ cell is in range or on range border /
(range.row0 <= row && row <= range.rowi \
&& range.col0 <= col && col <= range.coli)
/ cell is on range border /
(row == range.row0 || row == range.rowi \
|| col == range.col0 || col == range.coli)
/ some constants /
/ unrealized maximum width /
/ maximized: free space left for others /
/ unrealized maximum height /
/ maximized: free space left for others /
(sheet->sheet_window_width < COLUMN_REMNANT_PIXELS ? \
COLUMN_UNREALIZED_MAX_WIDTH : \
sheet->sheet_window_width - COLUMN_REMNANT_PIXELS )
(sheet->sheet_window_height < ROW_REMNANT_PIXELS ? \
ROW_UNREALIZED_MAX_HEIGHT : \
sheet->sheet_window_height - ROW_REMNANT_PIXELS )
(sheet->sheet_window_height < ROW_REMNANT_PIXELS ? \
ROW_UNREALIZED_MAX_HEIGHT : \
sheet->sheet_window_height * 1/3 )
(text_width + attr_border_width)
(text_height + attr_border_height)
(extent_width + 2*CELLOFFSET > COLUMN_MAX_WIDTH(sheet) ? \
COLUMN_MAX_WIDTH(sheet) : \
extent_width + 2*CELLOFFSET)
(extent_height + 2*CELLOFFSET > ROW_MAX_HEIGHT(sheet) ? \
ROW_MAX_HEIGHT(sheet) : \
extent_height + 2*CELLOFFSET)
/ GtkSheetRange macros /
((range)->row0 <= (row_0) && (row_i) <= (range)->rowi \
&& (range)->col0 <= (col_0) && (col_i) <= (range)->coli)
_RECT_IN_RANGE(row, row, col, col, range)
((row_0) == (range)->row0 && (row_i) == (range)->rowi \
&& (col_0) == (range)->col0 && (col_i) == (range)->coli)
((row_0) != (range)->row0 || (row_i) != (range)->rowi \
|| (col_0) != (range)->col0 || (col_i) != (range)->coli)
((range1)->row0 == (range2)->row0 && (range1)->rowi == (range2)->rowi \
&& (range1)->col0 == (range2)->col0 && (range1)->coli == (range2)->coli)
((range1)->row0) != (range2)->row0 || (range1)->rowi != (range2)->rowi \
|| (range1)->col0 != (range2)->col0 || (range1)->coli != (range2)->coli)
{ \
/*g_debug("%s(%d): SET_ACTIVE_CELL(%d, %d)", \
__FUNCTION__, __LINE__, (r), (c));*/ \
sheet->active_cell.row = (r); \
sheet->active_cell.col = (c); \
}
{ \
/*g_debug("%s(%d): SET_SELECTION_PIN(%d, %d)", \
__FUNCTION__, __LINE__, (r), (c));*/ \
sheet->selection_pin.row = (r); \
sheet->selection_pin.col = (c); \
}
{ \
/*g_debug("%s(%d): SET_SELECTION_CURSOR(%d, %d)", \
__FUNCTION__, __LINE__, (r), (c));*/ \
sheet->selection_cursor.row = (r); \
sheet->selection_cursor.col = (c); \
}
const guint gtksheet_major_version = GTKSHEET_MAJOR_VERSION; const guint gtksheet_minor_version = GTKSHEET_MINOR_VERSION; const guint gtksheet_micro_version = GTKSHEET_MICRO_VERSION;
gchar * gtksheet_check_version ( guint required_major, guint required_minor, guint required_micro) { if (required_major > GTKSHEET_MAJOR_VERSION) return "GtkExtra version too old (major mismatch)"; if (required_major < GTKSHEET_MAJOR_VERSION) return "GtkExtra version too new (major mismatch)"; if (required_minor > GTKSHEET_MINOR_VERSION) return "GtkExtra version too old (minor mismatch)"; if (required_minor < GTKSHEET_MINOR_VERSION) return "GtkExtra version too new (minor mismatch)"; if (required_micro > GTKSHEET_MICRO_VERSION) return "GtkExtra version too old (micro mismatch)"; return NULL; }
/ void _gtksheet_signal_test( GObject 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, G_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_BOOLEANEAN); 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 _gtksheet_signal_emit(GObject 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, G_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); }
/ defaults /
/ enable focus hunt when no active cell is set when sheet is shown /
/ size of tooltip marker, pixels /
/ number of rows to stay visible with PageUp/Dn /
static gdouble selection_border_width = DEFAULT_SELECTION_BORDER_WIDTH; static gdouble selection_border_offset = 0; / + to outside, - to inner /
/ beware: keep corner within border! / static gdouble selection_corner_size = DEFAULT_SELECTION_BORDER_WIDTH + DEFAULT_CORNER_EXTENT; static gdouble selection_corner_offset = -DEFAULT_CORNER_EXTENT;
static gdouble selection_bb_offset = 1; / border/background/
static GdkRGBA color_black; static GdkRGBA color_white;
static GdkRGBA debug_color;
static void _debug_cairo_clip_extent(gchar where, cairo_t cr) { double x1, y1, x2, y2; cairo_clip_extents (cr, &x1, &y1, &x2, &y2); g_debug( "%s: _debug_cairo_clip_extent: x1 %0.1f y1 %0.1f x2 %0.1f y2 %0.1f", where, x1, y1, x2, y2); }
static void _debug_color_rect( gchar where, cairo_t cr, double x, double y, double w, double h) { g_debug( "%s: _debug_color_rect: x %0.1f y %0.1f w %0.1f h %0.1f", where, x, y, w, h);
cairo_save(cr); // debug color
cairo_set_line_width(cr, 1.0);
cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT);
cairo_set_line_join(cr, CAIRO_LINE_JOIN_MITER);
gdk_cairo_set_source_rgba(cr, &debug_color);
cairo_rectangle(cr, x, y, w, h);
cairo_stroke(cr);
cairo_restore(cr); // debug color
}
static void g_debug_popup(char fmt, ...) / used to intercept/debug drawing sequences */ { va_list ap; va_start(ap, fmt);
GtkWidget *dialog = gtk_message_dialog_new (NULL,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
fmt, ap);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
static void g_debug_style_context_list_classes( gchar hint, GtkStyleContext context) { GList l = gtk_style_context_list_classes (context); while (l) { g_debug("%s: style_context class <%s>", hint, (gchar ) l->data); l = l->next; } g_list_free(l); }
/**
when there is no font associated / guint _gtk_sheet_row_default_height(GtkWidget widget) { PangoFontDescription font_desc = NULL; GtkStyleContext style_context = gtk_widget_get_style_context(widget);
GtkStateFlags flags = gtk_widget_get_state_flags(widget);
gtk_style_context_get(style_context, flags, GTK_STYLE_PROPERTY_FONT, &font_desc, NULL);
if (!font_desc) return (GTK_SHEET_ROW_DEFAULT_HEIGHT);
PangoContext *context = gtk_widget_get_pango_context(widget);
PangoFontMetrics *metrics = pango_context_get_metrics(context, 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); }
static inline guint _default_font_ascent(GtkWidget widget) { PangoFontDescription font_desc = NULL; GtkStyleContext *style_context = gtk_widget_get_style_context(widget);
gtk_style_context_get (style_context, GTK_STATE_FLAG_NORMAL,
GTK_STYLE_PROPERTY_FONT, &font_desc, NULL);
if (!font_desc)
return (GTK_SHEET_DEFAULT_FONT_ASCENT);
PangoContext *context = gtk_widget_get_pango_context(widget);
PangoFontMetrics *metrics = pango_context_get_metrics(context,
font_desc, pango_context_get_language(context));
guint val = pango_font_metrics_get_ascent(metrics);
pango_font_metrics_unref(metrics);
return (PANGO_PIXELS(val));
}
static void _get_string_extent(GtkSheet sheet, GtkSheetColumn colptr, PangoFontDescription font_desc, const gchar text, guint width, guint height) { PangoRectangle extent; PangoLayout *layout;
layout = gtk_widget_create_pango_layout(GTK_WIDGET(sheet), text);
pango_layout_set_font_description(layout, font_desc);
if (colptr && !gtk_sheet_autoresize_columns(sheet))
{
switch(colptr->wrap_mode)
{
case GTK_WRAP_NONE:
break;
case GTK_WRAP_CHAR:
pango_layout_set_width(layout, colptr->width * PANGO_SCALE);
pango_layout_set_wrap(layout, PANGO_WRAP_CHAR);
break;
case GTK_WRAP_WORD:
pango_layout_set_width(layout, colptr->width * PANGO_SCALE);
pango_layout_set_wrap(layout, PANGO_WRAP_WORD);
break;
case GTK_WRAP_WORD_CHAR:
pango_layout_set_width(layout, colptr->width * PANGO_SCALE);
pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
break;
}
}
pango_layout_get_pixel_extents(layout, NULL, &extent);
{
PangoContext *context = gtk_widget_get_pango_context(GTK_WIDGET(sheet));
PangoFontMetrics *metrics = pango_context_get_metrics(
context, font_desc, pango_context_get_language(context));
gint ascent = pango_font_metrics_get_ascent(metrics) / PANGO_SCALE;
gint descent = pango_font_metrics_get_descent(metrics) / PANGO_SCALE;
gint spacing = pango_layout_get_spacing(layout) / PANGO_SCALE;
pango_font_metrics_unref(metrics);
g_debug("_get_string_extent(%s): ext (%d, %d, %d, %d) asc %d desc %d spac %d",
text,
extent.x, extent.y,
extent.width, extent.height,
ascent, descent, spacing);
}
g_object_unref(G_OBJECT(layout));
if (width)
*width = extent.width;
if (height)
*height = extent.height;
}
static inline guint _default_font_descent(GtkWidget widget) { PangoFontDescription font_desc = NULL; GtkStyleContext *style_context = gtk_widget_get_style_context(widget);
gtk_style_context_get (style_context, GTK_STATE_FLAG_NORMAL,
GTK_STYLE_PROPERTY_FONT, &font_desc, NULL);
if (!font_desc)
return (GTK_SHEET_DEFAULT_FONT_DESCENT);
PangoContext *context = gtk_widget_get_pango_context(widget);
PangoFontMetrics *metrics = pango_context_get_metrics(context,
font_desc, pango_context_get_language(context));
guint val = pango_font_metrics_get_descent(metrics);
pango_font_metrics_unref(metrics);
return (PANGO_PIXELS(val));
}
/ gives the top/bottom pixel of the given row in context of the sheet's voffset /
static inline gint _gtk_sheet_row_top_ypixel(GtkSheet *sheet, gint row) { if (row < 0 || row > sheet->maxrow) return (sheet->voffset); return (sheet->voffset + sheet->row[row].top_ypixel); }
static inline gint _gtk_sheet_row_bottom_ypixel(GtkSheet *sheet, gint row) { gint ypixel = _gtk_sheet_row_top_ypixel(sheet, row); if (0 <= row && row <= sheet->maxrow) ypixel += sheet->row[row].height; return (ypixel); }
/**
static inline gint _gtk_sheet_row_from_ypixel(GtkSheet *sheet, gint y) { gint i, cy;
cy = sheet->voffset;
if (sheet->column_titles_visible)
cy += sheet->column_title_area.height;
if (y < cy)
return (-1); /* top outside */
for (i = 0; i <= sheet->maxrow; i++)
{
if (GTK_SHEET_ROW_IS_VISIBLE(ROWPTR(sheet, i)))
{
if (cy <= y && y < (cy + sheet->row[i].height))
return (i);
cy += sheet->row[i].height;
}
}
/* no match */
return (sheet->maxrow + 1);
}
/**
Returns: column index, or maxcol+1 (beyond right edge) / static inline gint _gtk_sheet_column_from_xpixel(GtkSheet sheet, gint x) { gint i, cx;
cx = sheet->hoffset; if (sheet->row_titles_visible) cx += sheet->row_title_area.width;
if (x < cx) { return (-1); / left outside / }
for (i = 0; i <= sheet->maxcol; i++) { if (GTK_SHEET_COLUMN_IS_VISIBLE(COLPTR(sheet, i))) { if (cx <= x && x < (cx + COLPTR(sheet, i)->width)) { return (i); } cx += COLPTR(sheet, i)->width; } }
/ no match / return (sheet->maxcol + 1); }
/**
/**
/**
/**
/**
returns: TRUE if any visible cells exist and range is valid / static inline gboolean _gtk_sheet_get_visible_range(GtkSheet sheet, GtkSheetRange *visr) { visr->row0 = visr->rowi = visr->col0 = visr->coli = -1;
visr->row0 = _gtk_sheet_first_visible_rowidx(sheet, 0); if (visr->row0 < 0) return (FALSE);
visr->rowi = _gtk_sheet_last_visible_rowidx(sheet, sheet->maxrow); if (visr->rowi < 0) return (FALSE);
visr->col0 = _gtk_sheet_first_visible_colidx(sheet, 0); if (visr->col0 < 0) return (FALSE);
visr->coli = _gtk_sheet_last_visible_colidx(sheet, sheet->maxcol); if (visr->coli < 0) return (FALSE);
return (TRUE); }
/**
count visible rows/cols in range / static inline void _gtk_sheet_count_visible(GtkSheet sheet, GtkSheetRange range, gint nrows, gint ncols) { gint i; nrows = *ncols = 0;
for (i = range->row0; i <= range->rowi; i++) { if (GTK_SHEET_ROW_IS_VISIBLE(ROWPTR(sheet, i))) ++(nrows); } for (i = range->col0; i <= range->coli; i++) { if (GTK_SHEET_COLUMN_IS_VISIBLE(COLPTR(sheet, i))) ++(ncols); } }
/**
col_titles area / static inline gint _gtk_sheet_height(GtkSheet sheet) { gint i, cx;
cx = (sheet->column_titles_visible ? sheet->column_title_area.height : 0);
for (i = 0; i <= sheet->maxrow; i++) { if (GTK_SHEET_ROW_IS_VISIBLE(ROWPTR(sheet, i))) cx += sheet->row[i].height; }
return (cx); }
/**
row_titles area / static inline gint _gtk_sheet_width(GtkSheet sheet) { gint i, cx;
cx = (sheet->row_titles_visible ? sheet->row_title_area.width : 0);
for (i = 0; i <= sheet->maxcol; i++) { if (GTK_SHEET_COLUMN_IS_VISIBLE(COLPTR(sheet, i))) cx += COLPTR(sheet, i)->width; }
return (cx); }
/**
recalculate visible sheet range / void _gtk_sheet_recalc_view_range(GtkSheet sheet) { sheet->view.row0 = _gtk_sheet_row_from_ypixel(sheet, sheet->column_titles_visible ? sheet->column_title_area.height : 0); sheet->view.rowi = _gtk_sheet_row_from_ypixel(sheet, sheet->sheet_window_height - 1);
sheet->view.col0 = _gtk_sheet_column_from_xpixel(sheet, sheet->row_titles_visible ? sheet->row_title_area.width : 0); sheet->view.coli = _gtk_sheet_column_from_xpixel(sheet, sheet->sheet_window_width - 1); }
/**
/**
g_debug("_gtk_sheet_invalidate_region %d %d %d %d", x, y, width, height);
cairo_rectangle_int_t rect = { x, y, width, height }; cairo_region_t *crg = cairo_region_create_rectangle(&rect); gdk_window_invalidate_region(sheet->sheet_window, crg, FALSE); cairo_region_destroy(crg); }
/*
@return / static inline gint POSSIBLE_XDRAG(GtkSheet sheet, gint x, gint *drag_column) { gint column, xdrag;
column = _gtk_sheet_column_from_xpixel(sheet, x); if (column < 0 || column > sheet->maxcol) return (FALSE);
xdrag = _gtk_sheet_column_left_xpixel(sheet, column);
if (column > 0 && x <= xdrag + DRAG_WIDTH / 2) / you pick it at the left border / { while (column > 0 && !GTK_SHEET_COLUMN_IS_VISIBLE(COLPTR(sheet, column - 1))) column--;
--column; / you really want to resize the column on the left side /
if (column < 0 || column > sheet->maxcol) return (FALSE);
*drag_column = column; return (TRUE);
return(GTK_SHEET_COLUMN_IS_SENSITIVE(COLPTR(sheet, column)));
}
xdrag = _gtk_sheet_column_right_xpixel(sheet, column);
if (xdrag - DRAG_WIDTH / 2 <= x && x <= xdrag + DRAG_WIDTH / 2) { *drag_column = column; return (TRUE);
return(GTK_SHEET_COLUMN_IS_SENSITIVE(COLPTR(sheet, column)));
}
return (FALSE); }
/*
@return / static inline gint POSSIBLE_YDRAG(GtkSheet sheet, gint y, gint *drag_row) { gint row, ydrag;
row = _gtk_sheet_row_from_ypixel(sheet, y); if (row < 0 || row > sheet->maxrow) return (FALSE);
ydrag = _gtk_sheet_row_top_ypixel(sheet, row);
if (row > 0 && y <= ydrag + DRAG_WIDTH / 2) / you pick it at the top border / { while (row > 0 && !GTK_SHEET_ROW_IS_VISIBLE(ROWPTR(sheet, row - 1))) row--;
--row; / you really want to resize the row above /
if (row < 0 || row > sheet->maxrow) return (FALSE);
*drag_row = row; return (TRUE);
return(GTK_SHEET_ROW_IS_SENSITIVE(ROWPTR(sheet, row)));
}
ydrag = _gtk_sheet_row_bottom_ypixel(sheet, row);
if (ydrag - DRAG_WIDTH / 2 <= y && y <= ydrag + DRAG_WIDTH / 2) { *drag_row = row; return (TRUE);
return(GTK_SHEET_ROW_IS_SENSITIVE(ROWPTR(sheet, row)));
}
return (FALSE); }
/*
@return / static inline gint POSSIBLE_DRAG(GtkSheet sheet, gint x, gint y, gint drag_row, gint drag_column) { gint ydrag, xdrag;
drag_column = _gtk_sheet_column_from_xpixel(sheet, x); drag_row = _gtk_sheet_row_from_ypixel(sheet, y);
/ drag grip at top/bottom border /
if (x >= _gtk_sheet_column_left_xpixel(sheet, sheet->range.col0) - DRAG_WIDTH / 2 && x <= _gtk_sheet_column_right_xpixel(sheet, sheet->range.coli) + DRAG_WIDTH / 2) { ydrag = _gtk_sheet_row_top_ypixel(sheet, sheet->range.row0);
if (ydrag - DRAG_WIDTH / 2 <= y && y <= ydrag + DRAG_WIDTH / 2) { *drag_row = sheet->range.row0; return (TRUE); }
ydrag = _gtk_sheet_row_bottom_ypixel(sheet, sheet->range.rowi);
if (ydrag - DRAG_WIDTH / 2 <= y && y <= ydrag + DRAG_WIDTH / 2) { *drag_row = sheet->range.rowi; return (TRUE); }
}
/ drag grip at left/right border /
if (y >= _gtk_sheet_row_top_ypixel(sheet, sheet->range.row0) - DRAG_WIDTH / 2 && y <= _gtk_sheet_row_bottom_ypixel(sheet, sheet->range.rowi) + DRAG_WIDTH / 2) { xdrag = _gtk_sheet_column_left_xpixel(sheet, sheet->range.col0);
if (xdrag - DRAG_WIDTH / 2 <= x && x <= xdrag + DRAG_WIDTH / 2) { *drag_column = sheet->range.col0; return (TRUE); }
xdrag = _gtk_sheet_column_right_xpixel(sheet, sheet->range.coli);
if (xdrag - DRAG_WIDTH / 2 <= x && x <= xdrag + DRAG_WIDTH / 2) { *drag_column = sheet->range.coli; return (TRUE); } }
return (FALSE); }
static inline gint POSSIBLE_RESIZE(GtkSheet sheet, gint x, gint y, gint drag_row, gint *drag_column) { gint xdrag, ydrag;
xdrag = _gtk_sheet_column_right_xpixel(sheet, sheet->range.coli);
ydrag = _gtk_sheet_row_bottom_ypixel(sheet, sheet->range.rowi);
if (sheet->state == GTK_SHEET_COLUMN_SELECTED)
ydrag = _gtk_sheet_row_top_ypixel(sheet, sheet->view.row0);
if (sheet->state == GTK_SHEET_ROW_SELECTED)
xdrag = _gtk_sheet_column_left_xpixel(sheet, sheet->view.col0);
*drag_column = _gtk_sheet_column_from_xpixel(sheet, x);
*drag_row = _gtk_sheet_row_from_ypixel(sheet, y);
if (xdrag - DRAG_WIDTH / 2 <= x && x <= xdrag + DRAG_WIDTH / 2 &&
ydrag - DRAG_WIDTH / 2 <= y && y <= ydrag + DRAG_WIDTH / 2)
{
return (TRUE);
}
return (FALSE);
}
/ Prototypes (extern) /
extern void _gtksheet_signal_emit(GObject *object, guint signal_id, ...);
/ Prototypes (static) /
static void gtk_sheet_class_init(GtkSheetClass klass); static void gtk_sheet_init(GtkSheet sheet); static void gtk_sheet_destroy_handler(GtkWidget widget); static void gtk_sheet_finalize_handler(GObject object); static void gtk_sheet_style_set_handler(GtkWidget widget, GtkStyle previous_style); static void gtk_sheet_realize_handler(GtkWidget widget); static void gtk_sheet_unrealize_handler(GtkWidget widget); static void gtk_sheet_map_handler(GtkWidget widget); static void gtk_sheet_unmap_handler(GtkWidget widget);
static gboolean gtk_sheet_draw(GtkWidget widget, cairo_t cr);
static void gtk_sheet_forall_handler(GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data);
static void gtk_sheet_set_scroll_adjustments(GtkSheet sheet, GtkAdjustment hadjustment, GtkAdjustment *vadjustment);
static gboolean gtk_sheet_button_press_handler(GtkWidget widget, GdkEventButton event); static gboolean gtk_sheet_button_release_handler(GtkWidget widget, GdkEventButton event); static gboolean gtk_sheet_motion_handler(GtkWidget widget, GdkEventMotion event);
static gboolean gtk_sheet_entry_key_press_handler(GtkWidget widget, GdkEventKey key, gpointer user_data);
static gboolean gtk_sheet_key_press_handler(GtkWidget widget, GdkEventKey key);
static void gtk_sheet_size_request(GtkWidget widget, GtkRequisition requisition); static void gtk_sheet_get_preferred_width (GtkWidget widget, gint minimal_width, gint natural_width); static void gtk_sheet_get_preferred_height (GtkWidget widget, gint minimal_height, gint natural_height); static void gtk_sheet_size_allocate_handler(GtkWidget widget, GtkAllocation allocation);
static gboolean gtk_sheet_focus(GtkWidget *widget, GtkDirectionType direction);
static void _gtk_sheet_move_cursor(GtkSheet *sheet, GtkMovementStep step, gint count, gboolean extend_selection);
/ Sheet queries /
static gint gtk_sheet_range_isvisible(GtkSheet sheet, GtkSheetRange range); static gint gtk_sheet_cell_isvisible(GtkSheet sheet, gint row, gint column);
/ Clipped Range /
static gint _gtk_sheet_scroll_to_pointer(gpointer data); static gint gtk_sheet_flash(gpointer data);
/ Drawing Routines /
/ draw cell background and frame / static void _cell_draw_background(GtkSheet sheet, gint row, gint column, cairo_t swin_cr);
/ draw cell border / static void _cell_draw_border(GtkSheet *sheet, gint row, gint column, gint mask);
/ draw cell contents / static void _cell_draw_label(GtkSheet sheet, gint row, gint column, cairo_t swin_cr);
/ highlight the visible part of the selected range / static void gtk_sheet_range_draw_selection( GtkSheet sheet, GtkSheetRange range, cairo_t cr);
/ Selection /
static gint _gtk_sheet_move_query( GtkSheet sheet, gint row, gint column, gboolean need_focus); static void gtk_sheet_real_select_range( GtkSheet sheet, GtkSheetRange range); static void gtk_sheet_real_unselect_range( GtkSheet sheet, GtkSheetRange range); static void gtk_sheet_extend_selection( GtkSheet sheet, gint row, gint column); static void gtk_sheet_new_selection( GtkSheet sheet, GtkSheetRange range); static void gtk_sheet_draw_border( GtkSheet sheet, GtkSheetRange range, cairo_t cr); static void gtk_sheet_draw_corners( GtkSheet sheet, GtkSheetRange range, cairo_t cr);
/ Active Cell handling /
static void gtk_sheet_entry_changed_handler( GtkWidget widget, gpointer data); static gboolean gtk_sheet_activate_cell( GtkSheet sheet, gint row, gint col); static void gtk_sheet_draw_active_cell(GtkSheet sheet, cairo_t cr); static void gtk_sheet_show_active_cell(GtkSheet sheet); void gtk_sheet_click_cell( GtkSheet sheet, gint row, gint column, gboolean *veto);
/ Backing Pixmap /
static void gtk_sheet_make_bsurf( GtkSheet sheet, guint width, guint height); static void gtk_sheet_draw_backing_pixmap( GtkSheet sheet, GtkSheetRange range, cairo_t *cr);
/ Scrollbars /
static void _vadjustment_changed_handler( GtkAdjustment adjustment, gpointer data); static void _hadjustment_changed_handler( GtkAdjustment adjustment, gpointer data); static void _vadjustment_value_changed_handler( GtkAdjustment adjustment, gpointer data); static void _hadjustment_value_changed_handler( GtkAdjustment adjustment, gpointer data);
static void draw_xor_vline(GtkSheet sheet, gboolean draw); static void draw_xor_hline(GtkSheet sheet, gboolean draw); static void gtk_sheet_draw_flashing_range( GtkSheet sheet, cairo_t xor_cr); static guint new_column_width(GtkSheet sheet, gint column, gint x); static guint new_row_height(GtkSheet sheet, gint row, gint y);
/ Sheet Entry /
static void create_sheet_entry(GtkSheet sheet, GType new_entry_type); //static void gtk_sheet_entry_set_max_size(GtkSheet sheet);
/ Sheet button gadgets /
static void _gtk_sheet_row_buttons_size_allocate(GtkSheet *sheet);
static void row_button_set(GtkSheet sheet, gint row); static void row_button_release(GtkSheet sheet, gint row);
/ global sheet button / static void _global_sheet_button_create(GtkSheet sheet); static void _global_sheet_button_size_allocate(GtkSheet sheet);
/ Attributes routines /
static void gtk_sheet_set_cell_attributes(GtkSheet sheet, gint row, gint col, GtkSheetCellAttr attributes); static void init_attributes(GtkSheet sheet, gint col, GtkSheetCellAttr *attributes);
/ Memory allocation routines / static void gtk_sheet_real_range_clear(GtkSheet sheet, const GtkSheetRange range, gboolean delete); static void gtk_sheet_real_cell_clear(GtkSheet *sheet, gint row, gint column, gboolean delete);
static GtkSheetCell *gtk_sheet_cell_new(void);
static void AddRows(GtkSheet sheet, gint position, gint nrows); static void AddColumns(GtkSheet sheet, gint position, gint ncols); static void InsertRow(GtkSheet sheet, gint row, gint nrows); static void InsertColumn(GtkSheet sheet, gint col, gint ncols); static void DeleteRow(GtkSheet sheet, gint row, gint nrows); static void DeleteColumn(GtkSheet sheet, gint col, gint ncols); static gint GrowSheet(GtkSheet sheet, gint newrows, gint newcols); static void CheckBounds(GtkSheet sheet, gint row, gint col); static void CheckCellData(GtkSheet *sheet, const gint row, const gint col);
/ Container Functions / static void gtk_sheet_remove_handler( GtkContainer container, GtkWidget widget); static void gtk_sheet_realize_child( GtkSheet sheet, GtkSheetChild child); static void gtk_sheet_position_child( GtkSheet sheet, GtkSheetChild child); static void gtk_sheet_row_size_request( GtkSheet sheet, gint row, guint requisition);
/ GtkBuildableIface /
/*
void gtk_sheet_buildable_add_child_internal(GtkSheet sheet, GtkSheetColumn child, const char *name) {
g_return_if_fail(GTK_IS_SHEET(sheet));
g_return_if_fail(GTK_IS_SHEET_COLUMN(child));
gtk_sheet_add_column(sheet, 1);
int col = gtk_sheet_get_columns_count(sheet) - 1;
if (sheet->column[col])
{
COLPTR(sheet, col)->sheet = NULL;
g_object_unref(sheet->column[col]);
sheet->column[col] = NULL;
}
child->sheet = sheet;
sheet->column[col] = child;
g_object_ref_sink(G_OBJECT(child));
g_debug("%s(%d): %p %s child %s %p name %s m %d r %d v %d",
__FUNCTION__, __LINE__,
sheet, gtk_widget_get_name(GTK_WIDGET(sheet)),
G_OBJECT_TYPE_NAME(child), child,
name ? name : "NULL",
gtk_widget_get_mapped(GTK_WIDGET(child)),
gtk_widget_get_realized(GTK_WIDGET(child)),
gtk_widget_get_visible(GTK_WIDGET(child))
);
/* we always set the parent in order to track into what sheet the column belongs,
which leads to problems with invisible columns.
When trying to set them visible, Gtk 2.24.5 terminates the application with
? Gtk - gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
see also the fix in gtk_sheet_column_set_visibility()
*/
DEBUG_WIDGET_SET_PARENT(child, sheet);
gtk_widget_set_parent(GTK_WIDGET(child), GTK_WIDGET(sheet));
if (gtk_widget_get_realized(GTK_WIDGET(sheet))
&& GTK_IS_SHEET_COLUMN(child))
{
_gtk_sheet_column_realize(child, sheet);
_gtk_sheet_column_check_windows(child, sheet);
}
if (name)
gtk_widget_set_name(GTK_WIDGET(child), name);
_gtk_sheet_reset_text_column(sheet, col);
_gtk_sheet_recalc_left_xpixels(sheet);
}
static void gtk_sheet_buildable_add_child( GtkBuildable buildable, GtkBuilder builder, GObject child, const gchar type) { const gchar *name = gtk_widget_get_name(GTK_WIDGET(child));
g_debug("gtk_sheet_buildable_add_child %p: %s type %s", child,
name ? name : "NULL",
type ? type : "NULL");
GtkSheet *sheet = GTK_SHEET(buildable);
GtkSheetColumn *newcol = GTK_SHEET_COLUMN(child);
{
gchar *strval;
g_object_get(G_OBJECT(newcol), "label", &strval, NULL);
g_debug("gtk_sheet_buildable_add_child: label=%s",
strval ? strval : "NULL");
g_free(strval);
}
gtk_sheet_buildable_add_child_internal(sheet, newcol, name);
}
static void gtk_sheet_buildable_init(GtkBuildableIface *iface) {
g_debug("gtk_sheet_buildable_init");
iface->add_child = gtk_sheet_buildable_add_child;
}
static GtkSheetArea gtk_sheet_get_area_at(GtkSheet *sheet, gint x, gint y) { if (sheet->column_titles_visible && (y < sheet->column_title_area.height)) { if (sheet->row_titles_visible && (x < sheet->row_title_area.width)) return (ON_SHEET_BUTTON_AREA);
return (ON_COLUMN_TITLES_AREA);
}
else
{
if (sheet->row_titles_visible && (x < sheet->row_title_area.width))
return (ON_ROW_TITLES_AREA);
}
return (ON_CELL_AREA);
}
/*
@return TRUE or FALSE wether to show the tip or not / static gboolean gtk_sheet_query_tooltip_handler(GtkWidget widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip tooltip, gpointer user_data) { gchar tip; GtkSheetArea area; gint row = -1, col = -1; GtkSheet *sheet = GTK_SHEET(widget);
if (!sheet) return (FALSE);
area = gtk_sheet_get_area_at(sheet, x, y);
if (area == ON_CELL_AREA) { if (row < 0) row = _gtk_sheet_row_from_ypixel(sheet, y); if (col < 0) col = _gtk_sheet_column_from_xpixel(sheet, x);
if ((0 <= row && row <= sheet->maxrow && 0 <= col && col <= sheet->maxcol) && (row <= sheet->maxallocrow && col <= sheet->maxalloccol) && (sheet->data[row] && sheet->data[row][col])) { GtkSheetCell *cell = sheet->data[row][col];
tip = cell->tooltip_markup;
if (tip && tip[0])
{
gtk_tooltip_set_markup(tooltip, tip);
return (TRUE);
}
tip = cell->tooltip_text;
if (tip && tip[0])
{
gtk_tooltip_set_text(tooltip, tip);
return (TRUE);
}
}
area = ON_ROW_TITLES_AREA; / fallback / }
if (area == ON_ROW_TITLES_AREA) { if (row < 0) row = _gtk_sheet_row_from_ypixel(sheet, y);
if (0 <= row && row <= sheet->maxrow) { GtkSheetRow *rowp = ROWPTR(sheet, row);
tip = rowp->tooltip_markup;
if (tip && tip[0])
{
gtk_tooltip_set_markup(tooltip, tip);
return (TRUE);
}
tip = rowp->tooltip_text;
if (tip && tip[0])
{
gtk_tooltip_set_text(tooltip, tip);
return (TRUE);
}
}
area = ON_COLUMN_TITLES_AREA; / fallback / }
if (area == ON_COLUMN_TITLES_AREA) { if (col < 0) col = _gtk_sheet_column_from_xpixel(sheet, x);
if (0 <= col && col <= sheet->maxcol) { GtkSheetColumn *column = COLPTR(sheet, col);
tip = gtk_widget_get_tooltip_markup(GTK_WIDGET(column));
if (tip && tip[0])
{
gtk_tooltip_set_markup(tooltip, tip);
g_free(tip);
return (TRUE);
}
tip = gtk_widget_get_tooltip_text(GTK_WIDGET(column));
if (tip && tip[0])
{
gtk_tooltip_set_text(tooltip, tip);
g_free(tip);
return (TRUE);
}
} }
/ fallback to sheet tip /
tip = gtk_widget_get_tooltip_markup(widget); if (tip && tip[0]) { gtk_tooltip_set_markup(tooltip, tip); g_free(tip); return (TRUE); }
tip = gtk_widget_get_tooltip_text(widget); if (tip && tip[0]) { gtk_tooltip_set_text(tooltip, tip); g_free(tip); return (TRUE); }
return (FALSE); }
/ Type initialisation /
static GtkContainerClass *sheet_parent_class = NULL;
GType gtk_sheet_get_type(void) { static GType sheet_type = 0;
if (!sheet_type)
{
static const GTypeInfo sheet_info =
{
sizeof(GtkSheetClass),
NULL,
NULL,
(GClassInitFunc)gtk_sheet_class_init,
NULL,
NULL,
sizeof(GtkSheet),
0,
(GInstanceInitFunc)gtk_sheet_init,
NULL,
};
sheet_type = g_type_register_static(gtk_container_get_type(),
"GtkSheet",
&sheet_info,
0);
static const GInterfaceInfo interface_info = {
(GInterfaceInitFunc)gtk_sheet_buildable_init,
(GInterfaceFinalizeFunc)NULL,
(gpointer)NULL
};
g_type_add_interface_static(sheet_type, GTK_TYPE_BUILDABLE,
&interface_info);
static const GInterfaceInfo scrollable_info = {
(GInterfaceInitFunc) NULL,
(GInterfaceFinalizeFunc) NULL,
(gpointer) NULL
};
g_type_add_interface_static(sheet_type, GTK_TYPE_SCROLLABLE,
&scrollable_info);
}
return (sheet_type);
}
static GtkSheetRange gtk_sheet_range_copy(const GtkSheetRange range) { GtkSheetRange *new_range;
g_return_val_if_fail(range != NULL, NULL);
new_range = g_new(GtkSheetRange, 1);
*new_range = *range;
return (new_range);
}
static void gtk_sheet_range_free(GtkSheetRange *range) { g_return_if_fail(range != NULL);
g_free(range);
}
GType gtk_sheet_range_get_type(void) { static GType sheet_range_type = 0;
if (!sheet_range_type)
{
sheet_range_type = g_boxed_type_register_static("GtkSheetRange", (GBoxedCopyFunc)gtk_sheet_range_copy, (GBoxedFreeFunc)gtk_sheet_range_free);
}
return (sheet_range_type);
}
/**
Returns: #GtkSheetEntryType or #GTK_SHEET_ENTRY_TYPE_DEFAULT */ GtkSheetEntryType _gtk_sheet_entry_type_from_gtype(GType entry_type) { if (entry_type == GTK_TYPE_ENTRY) return (GTK_SHEET_ENTRY_TYPE_GTK_ENTRY);
else if (entry_type == GTK_TYPE_TEXT_VIEW) return (GTK_SHEET_ENTRY_TYPE_GTK_TEXT_VIEW);
else if (entry_type == GTK_TYPE_DATA_ENTRY) return (GTK_SHEET_ENTRY_TYPE_GTK_DATA_ENTRY);
else if (entry_type == GTK_TYPE_DATA_TEXT_VIEW) return (GTK_SHEET_ENTRY_TYPE_GTK_DATA_TEXT_VIEW);
else if (entry_type == GTK_TYPE_SPIN_BUTTON) return (GTK_SHEET_ENTRY_TYPE_GTK_SPIN_BUTTON);
else if (entry_type == GTK_TYPE_COMBO_BOX) return (GTK_SHEET_ENTRY_TYPE_GTK_COMBO_BOX);
else if (entry_type == GTK_TYPE_COMBO_BOX_ENTRY)
return (GTK_SHEET_ENTRY_TYPE_GTK_COMBO_BOX_ENTRY);
else if (entry_type == GTK_TYPE_COMBO)
return (GTK_SHEET_ENTRY_TYPE_GTK_COMBO);
return (GTK_SHEET_ENTRY_TYPE_DEFAULT);
}
/**
Returns: #GType or #G_TYPE_NONE */ GType _gtk_sheet_entry_type_to_gtype(GtkSheetEntryType ety) { switch(ety) { case GTK_SHEET_ENTRY_TYPE_GTK_ENTRY: return (GTK_TYPE_ENTRY);
case GTK_SHEET_ENTRY_TYPE_GTK_TEXT_VIEW: return (GTK_TYPE_TEXT_VIEW);
case GTK_SHEET_ENTRY_TYPE_GTK_DATA_ENTRY: return (GTK_TYPE_DATA_ENTRY);
case GTK_SHEET_ENTRY_TYPE_GTK_DATA_TEXT_VIEW: return (GTK_TYPE_DATA_TEXT_VIEW);
case GTK_SHEET_ENTRY_TYPE_GTK_SPIN_BUTTON: return (GTK_TYPE_SPIN_BUTTON);
case GTK_SHEET_ENTRY_TYPE_GTK_COMBO_BOX: return (GTK_TYPE_COMBO_BOX);
case GTK_SHEET_ENTRY_TYPE_GTK_COMBO_BOX_ENTRY:
return (GTK_TYPE_COMBO_BOX_ENTRY);
case GTK_SHEET_ENTRY_TYPE_GTK_COMBO:
return (GTK_TYPE_COMBO);
default:
break;
}
return (G_TYPE_NONE);
}
/*
static void gtk_sheet_set_property(GObject object, guint property_id, const GValue value, GParamSpec pspec) { GtkSheet sheet = GTK_SHEET(object);
g_debug("gtk_sheet_set_property: %s", pspec->name);
switch(property_id)
{
case PROP_GTK_SHEET_TITLE:
gtk_sheet_set_title(sheet, g_value_get_string(value));
break;
case PROP_GTK_SHEET_DESCRIPTION:
gtk_sheet_set_description(sheet, g_value_get_string(value));
break;
case PROP_GTK_SHEET_NROWS:
{
gint newval = g_value_get_int(value);
if (newval < 0)
break;
g_debug("gtk_sheet_set_property: newval = %d sheet->maxrow %d", newval, sheet->maxrow);
if (newval < (sheet->maxrow + 1))
{
gtk_sheet_delete_rows(sheet, newval, (sheet->maxrow + 1) - newval);
_gtk_sheet_recalc_view_range(sheet);
}
else if (newval > (sheet->maxrow + 1))
{
gtk_sheet_add_row(sheet, newval - (sheet->maxrow + 1));
_gtk_sheet_recalc_view_range(sheet);
}
}
break;
case PROP_GTK_SHEET_NCOLS:
{
gint newval = g_value_get_int(value);
if (newval < 0)
break;
g_debug("gtk_sheet_set_property: newval = %d sheet->maxcol %d", newval, sheet->maxcol);
if (newval < (sheet->maxcol + 1))
{
gtk_sheet_delete_columns(sheet, newval, (sheet->maxcol + 1) - newval);
_gtk_sheet_recalc_view_range(sheet);
}
else if (newval > (sheet->maxcol + 1))
{
gtk_sheet_add_column(sheet, newval - (sheet->maxcol + 1));
_gtk_sheet_recalc_view_range(sheet);
}
}
break;
case PROP_GTK_SHEET_LOCKED:
gtk_sheet_set_locked(sheet, g_value_get_boolean(value));
break;
case PROP_GTK_SHEET_SELECTION_MODE:
gtk_sheet_set_selection_mode(sheet, g_value_get_enum(value));
break;
case PROP_GTK_SHEET_AUTO_RESIZE:
gtk_sheet_set_autoresize(sheet, g_value_get_boolean(value));
break;
case PROP_GTK_SHEET_AUTO_RESIZE_ROWS:
gtk_sheet_set_autoresize_rows(sheet, g_value_get_boolean(value));
break;
case PROP_GTK_SHEET_AUTO_RESIZE_COLUMNS:
gtk_sheet_set_autoresize_columns(sheet, g_value_get_boolean(value));
break;
case PROP_GTK_SHEET_AUTO_SCROLL:
gtk_sheet_set_autoscroll(sheet, g_value_get_boolean(value));
break;
case PROP_GTK_SHEET_CLIP_TEXT:
gtk_sheet_set_clip_text(sheet, g_value_get_boolean(value));
break;
case PROP_GTK_SHEET_JUSTIFY_ENTRY:
gtk_sheet_set_justify_entry(sheet, g_value_get_boolean(value));
break;
case PROP_GTK_SHEET_BG_COLOR:
gtk_sheet_set_background(sheet, g_value_get_boxed(value));
break;
case PROP_GTK_SHEET_GRID_VISIBLE:
gtk_sheet_show_grid(sheet, g_value_get_boolean(value));
break;
case PROP_GTK_SHEET_GRID_COLOR:
gtk_sheet_set_grid(sheet, g_value_get_boxed(value));
break;
case PROP_GTK_SHEET_COLUMN_TITLES_VISIBLE:
if (g_value_get_boolean(value))
gtk_sheet_show_column_titles(sheet);
else
gtk_sheet_hide_column_titles(sheet);
break;
case PROP_GTK_SHEET_COLUMNS_RESIZABLE:
gtk_sheet_columns_set_resizable(sheet, g_value_get_boolean(value));
break;
case PROP_GTK_SHEET_COLUMN_TITLES_HEIGHT:
gtk_sheet_set_column_titles_height(sheet, g_value_get_uint(value));
break;
case PROP_GTK_SHEET_ROW_TITLES_VISIBLE:
if (g_value_get_boolean(value))
gtk_sheet_show_row_titles(sheet);
else
gtk_sheet_hide_row_titles(sheet);
break;
case PROP_GTK_SHEET_ROWS_RESIZABLE:
gtk_sheet_rows_set_resizable(sheet, g_value_get_boolean(value));
break;
case PROP_GTK_SHEET_ROW_TITLES_WIDTH:
gtk_sheet_set_row_titles_width(sheet, g_value_get_uint(value));
break;
case PROP_GTK_SHEET_ENTRY_TYPE:
{
GType entry_type = _gtk_sheet_entry_type_to_gtype(g_value_get_enum(value));
sheet->entry_type = entry_type; /* wanted entry type */
gtk_sheet_change_entry(sheet, entry_type);
}
break;
case PROP_GTK_SHEET_VJUST:
gtk_sheet_set_vjustification(sheet, g_value_get_enum(value));
break;
case PROP_GTK_SHEET_HADJUSTMENT:
gtk_sheet_set_hadjustment(sheet, g_value_get_object (value));
break;
case PROP_GTK_SHEET_VADJUSTMENT:
gtk_sheet_set_vadjustment(sheet, g_value_get_object (value));
break;
case PROP_GTK_SHEET_HSCROLL_POLICY:
if (sheet->hscroll_policy != g_value_get_enum (value))
{
sheet->hscroll_policy = g_value_get_enum (value);
gtk_widget_queue_resize (GTK_WIDGET (sheet));
g_object_notify_by_pspec (object, pspec);
}
break;
case PROP_GTK_SHEET_VSCROLL_POLICY:
if (sheet->vscroll_policy != g_value_get_enum (value))
{
sheet->vscroll_policy = g_value_get_enum (value);
gtk_widget_queue_resize (GTK_WIDGET (sheet));
g_object_notify_by_pspec (object, pspec);
}
break;
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
break;
}
_gtk_sheet_range_draw(sheet, NULL, TRUE);
/* this one will not work, it simply does noop
gtk_widget_queue_draw(GTK_WIDGET(sheet));*/ }
static void gtk_sheet_get_property(GObject object, guint property_id, GValue value, GParamSpec pspec) { GtkSheet sheet = GTK_SHEET(object);
switch(property_id)
{
case PROP_GTK_SHEET_TITLE:
g_value_set_string(value, sheet->title);
break;
case PROP_GTK_SHEET_DESCRIPTION:
g_value_set_string(value, sheet->description);
break;
case PROP_GTK_SHEET_NROWS:
g_value_set_int(value, sheet->maxrow + 1);
break;
case PROP_GTK_SHEET_NCOLS:
g_value_set_int(value, sheet->maxcol + 1);
break;
case PROP_GTK_SHEET_LOCKED:
g_value_set_boolean(value, sheet->locked);
break;
case PROP_GTK_SHEET_SELECTION_MODE:
g_value_set_enum(value, sheet->selection_mode);
break;
case PROP_GTK_SHEET_AUTO_RESIZE:
g_value_set_boolean(value, gtk_sheet_autoresize(sheet));
break;
case PROP_GTK_SHEET_AUTO_RESIZE_ROWS:
g_value_set_boolean(value, gtk_sheet_autoresize_rows(sheet));
break;
case PROP_GTK_SHEET_AUTO_RESIZE_COLUMNS:
g_value_set_boolean(value, gtk_sheet_autoresize_columns(sheet));
break;
case PROP_GTK_SHEET_AUTO_SCROLL:
g_value_set_boolean(value, sheet->autoscroll);
break;
case PROP_GTK_SHEET_CLIP_TEXT:
g_value_set_boolean(value, sheet->clip_text);
break;
case PROP_GTK_SHEET_JUSTIFY_ENTRY:
g_value_set_boolean(value, sheet->justify_entry);
break;
case PROP_GTK_SHEET_BG_COLOR:
g_value_set_boxed(value, &sheet->bg_color);
break;
case PROP_GTK_SHEET_GRID_VISIBLE:
g_value_set_boolean(value, sheet->show_grid);
break;
case PROP_GTK_SHEET_GRID_COLOR:
g_value_set_boxed(value, &sheet->grid_color);
break;
case PROP_GTK_SHEET_COLUMN_TITLES_VISIBLE:
g_value_set_boolean(value, sheet->column_titles_visible);
break;
case PROP_GTK_SHEET_COLUMNS_RESIZABLE:
g_value_set_boolean(value, sheet->columns_resizable);
break;
case PROP_GTK_SHEET_COLUMN_TITLES_HEIGHT:
g_value_set_uint(value, sheet->column_title_area.height);
break;
case PROP_GTK_SHEET_ROW_TITLES_VISIBLE:
g_value_set_boolean(value, sheet->row_titles_visible);
break;
case PROP_GTK_SHEET_ROWS_RESIZABLE:
g_value_set_boolean(value, sheet->rows_resizable);
break;
case PROP_GTK_SHEET_ROW_TITLES_WIDTH:
g_value_set_uint(value, sheet->row_title_area.width);
break;
case PROP_GTK_SHEET_ENTRY_TYPE:
g_value_set_enum(value, _gtk_sheet_entry_type_from_gtype(sheet->entry_type));
break;
case PROP_GTK_SHEET_VJUST:
g_value_set_enum(value, sheet->vjust);
break;
case PROP_GTK_SHEET_HADJUSTMENT:
g_value_set_object(value, sheet->hadjustment);
break;
case PROP_GTK_SHEET_VADJUSTMENT:
g_value_set_object(value, sheet->vadjustment);
break;
case PROP_GTK_SHEET_HSCROLL_POLICY:
g_value_set_enum (value, sheet->hscroll_policy);
break;
case P
Hello FPaquet, I know that you join two projects: gtkextra and gtksheet. gtkextra includes a gtksheet. I want to know what are differences between the gtksheet in the gtkextra and the single gtksheet? Which one should we use? I found the multiple issues in the single gtksheet version 4.2.0, 4.3.0 and 4.3.5. I want to report them. But I can not report them in git like before. I do not why? Thanks, Song
From: Fredy Paquet notifications@github.com Sent: March 9, 2019 5:37 AM To: fpaquet/gtksheet gtksheet@noreply.github.com Cc: songqingshan shans123@hotmail.com; Author author@noreply.github.com Subject: Re: [fpaquet/gtksheet] gtksheet crashes (#10)
I've now released V4.3.0 for Gtk3 (branch gtk3) https://github.com/fpaquet/gtksheet/releases/tag/V4.3.0
And published online docs V4 https://fpaquet.github.io/gtksheet/reference/index.html
This should fix the crash issue.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/fpaquet/gtksheet/issues/10#issuecomment-471169673, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ApTBUxuwqHSiVBt7ZpmCu1U0iR9fvQTBks5vU5zhgaJpZM4ZdUr8.
Hello Song Nobody was taking care of the plot widgets in GtkExtra. So i moved the sheet code into the GtkSheet project. GtkExtra is dead and unmaintained. You should be able to report bugs to the GtkSheet project.
I can not report them in git like before.
I'm not aware of any problems with the github bug tracking system. Someone created a new issue no 26 on 28 Jul 2020.
Can you describe what happens when you try to create a new issue?
Hello Fredy,
I appreciate your reply. the plot widgets in GtkExtra are very useful and important in the scientific community. I believe that the reason "Nobody was taking care of the plot widgets in GtkExtra" is just because nobody knows. Can GtkExtra be used for Gtk3? If not, what do we need to do for advancing GtkExtra for Gtk3? any suggestions? I will try to report some glitches and bugs in the gtksheet in git later. If still can not do it, I will copy them to you. Thank you, Song
From: Fredy Paquet notifications@github.com Sent: September 19, 2020 12:54 AM To: fpaquet/gtksheet gtksheet@noreply.github.com Cc: songqingshan shans123@hotmail.com; Author author@noreply.github.com Subject: Re: [fpaquet/gtksheet] gtksheet crashes (#10)
Hello Song Nobody was taking care of the plot widgets in GtkExtra. So i moved the sheet code into the GtkSheet project. GtkExtra is dead and unmaintained. You should be able to report bugs to the GtkSheet project.
I can not report them in git like before.
I'm not aware of any problems with the github bug tracking system. Someone created a new issue no 26 on 28 Jul 2020.
Can you describe what happens when you try to create a new issue?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/fpaquet/gtksheet/issues/10#issuecomment-695169740, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKKMCU2FK5FOYMDAYTS7AE3SGRBQVANCNFSM4GLVJL6A.
Hello Song
The main repo of GtkExtra is hosted on SourceForge. I was publishing request for a new maintainer in April 2018. http://gtkextra.sourceforge.net/cms/index.php?option=com_content&view=article&id=63:new-maintainer-searched&catid=3:news
A google search reveals multiple forks and also a discussion about Gtk3 port of GtkExtra https://stackoverflow.com/questions/22907417/can-gtkextra-work-with-gtk3
Before splitting the GtkSheet into a separate project, i was starting to add support for Gtk3. Have a look at the gtk3 branch there. I managed to get ONE of the plot widgets running with Gtk3, but capitulated on the other plot widgets due to lack of documentation and deeper understanding of the functionality.
Adrian E. Feiguin (the initiator of GtkExtra) quit the project more than 10 years ago. Since then, he didn't respond to my e-mails any further.
Hello Fredy Paquet, I appreciate your insistency and contribution to gtkextra and gtksheet. I also believe many people do so. Although gtksheet still has some glitches and bugs, it has been used in some applications. Without your effort, there is not today's gtksheet. Regarding gtkextra, You mentioned "Have a look at the gtk3 branch there. I managed to get ONE of the plot widgets running with Gtk3,...". But I can not find the gtk3 branch. Can you send me a link? I would like to take a look at it. Thanks, Song
From: Fredy Paquet notifications@github.com Sent: September 20, 2020 2:30 AM To: fpaquet/gtksheet gtksheet@noreply.github.com Cc: songqingshan shans123@hotmail.com; Author author@noreply.github.com Subject: Re: [fpaquet/gtksheet] gtksheet crashes (#10)
Hello Song
The main repo of GtkExtra is hosted on SourceForge. I was publishing request for a new maintainer in April 2018. http://gtkextra.sourceforge.net/cms/index.php?option=com_content&view=article&id=63:new-maintainer-searched&catid=3:news
A google search reveals multiple forks and also a discussion about Gtk3 port of GtkExtra https://stackoverflow.com/questions/22907417/can-gtkextra-work-with-gtk3
Before splitting the GtkSheet into a separate project, i was starting to add support for Gtk3. Have a look at the gtk3 branch there. I managed to get ONE of the plot widgets running with Gtk3, but capitulated on the other plot widgets due to lack of documentation and deeper understanding of the functionality.
Adrian E. Feiguin (the initiator of GtkExtra) quit the project more than 10 years ago. Since then, he didn't respond to my e-mails any further.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/fpaquet/gtksheet/issues/10#issuecomment-695755614, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKKMCUYPM5H7ONMTXLC6Z4LSGWVSBANCNFSM4GLVJL6A.
When you browse sf repo, you can see branches on the left side https://sourceforge.net/p/gtkextra/gtkextra-3/ci/master/tree/
Or simply clone the repo, then use 'git checkout gtk3'
Hello Fredy Paquet, I appreciate your help. I down load this version and compile it successfully yesterday. Since README says it requires GTK+ 2.14.4, I assumed that I down load the wrong version. Thanks for your clarifying it.
I compile and try the gtkextra-3, gtkextra-3.3.4,gtksheet-4.2.0, gtksheet-4.3.0, and gtksheet-4.3.5. The grid in gtksheet-4.3.0 and gtksheet-4.3.5 did not show (missing). The grid in gtkextra-3, gtkextra-3.3.4,and gtksheet-4.2.0 shows well. I try to report other glitches and bugs in gtksheet-4.3.5 again, but new issue button still is dead. Thanks for your help. Regards, Song
From: Fredy Paquet notifications@github.com Sent: September 20, 2020 11:58 AM To: fpaquet/gtksheet gtksheet@noreply.github.com Cc: songqingshan shans123@hotmail.com; Author author@noreply.github.com Subject: Re: [fpaquet/gtksheet] gtksheet crashes (#10)
When you browse sf repo, you can see branches on the left side https://sourceforge.net/p/gtkextra/gtkextra-3/ci/master/tree/
Or simply clone the repo, then use 'git checkout gtk3'
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/fpaquet/gtksheet/issues/10#issuecomment-695809857, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKKMCU66JFBX62TSOIDDYXDSGYYCZANCNFSM4GLVJL6A.
Are you using this page for GtkSheet issues? https://github.com/fpaquet/gtksheet/issues
I can see a green button "New Issue", which is active. The same button also on top of this page here, it's active.
testgtksheet.exe crashes. I have tried gtksheet testgtksheet.exe under msys2/mingw64. There are three pages (e.g., folder 1, folder 2, and folder 3). If you start from page 1(folder 1), it works. if you visit other two pages (folder 2 or folder 3 or both) after visiting page 1, then you go back to the page 1 and the button "Show me a calendar" disappears. When clicking the some areas on the same page, the button maybe shows again (the best scenario), maybe disappears forever, maybe the program crashes (worst scenario), maybe shows warning "(testgtksheet.exe:3508): GLib-CRITICAL **: 22:43:05.957: Source ID 2344 was not found when attempting to remove it". I check following link: https://stackoverflow.com/questions/23199699/glib-critical-source-id-xxx-was-not-found-when-attempting-to-remove-it. It says "This isn't a bug in your code, and it's not a crash either. It's actually just a warning that g_source_remove() was called to disconnect a certain event handler that was already disconnected, in this case, in code that is part of gtk." I believe this kind of saying is incorrect. testgtksheet.exe crashes. In addition, I make a small sheet with a button cell using gtksheet. first, the button can be seen. If we visit others, then come to the same page with the button. The button disappears forever (similar to testgtksheet.exe).