Commit c929518c authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

restore this and have it use io-context. (gnumeric_1_0_dtd) : fix.

2002-09-23  Jody Goldberg <jody@gnome.org>

	* xml-sax-read.c (unknown_attr) : restore this and have it use
	  io-context.
	(gnumeric_1_0_dtd) : fix.
	(xml_sax_style_region_start) : Use new_default for newer versions

2002-09-23  Lutz Mller <lutz@users.sourceforge.net>

	* src/workbook-control-gui.c: Implement reordering of sheets via
	  drag & drop within workbooks.
parent 2fbc774b
2002-09-23 Lutz Mller <lutz@users.sourceforge.net>
* src/workbook-control-gui.c: Implement reordering of sheets via
drag & drop within workbooks.
2002-09-23 Jody Goldberg <jody@gnome.org>
* src/sheet-view.c (sv_update) : see if there is a named expression that
......
......@@ -25,8 +25,9 @@ Jody:
* Fix sheet object ref counting error that Morten found.
* Fix crash when destroying unshared view.
* Start fleshing out support signals to give scripting more power
* Move the CORBA support code into a plugin and make it functional.
* Add some UI for managing hyperlinks of various sorts.
* Move the CORBA support code into a plugin and make more functional.
* Add some UI for managing hyperlinks of various sorts (unfinished)
* Make the location status box smarter about named ranges
Michael Meeks:
* Spruce up the CORBA code to use some bonobo utils.
......@@ -38,6 +39,9 @@ Morten:
* Really make autocorrect utf8 safe.
* Add FIB function.
Lutz Müller:
* Drag & Drop sheet re-ordering
--------------------------------------------------------------------------
Gnumeric 1.1.8
......
2002-09-23 Lutz Mller <lutz@users.sourceforge.net>
* src/workbook-control-gui.c: Implement reordering of sheets via
drag & drop within workbooks.
2002-09-23 Jody Goldberg <jody@gnome.org>
* src/sheet-view.c (sv_update) : see if there is a named expression that
......
2002-09-23 Lutz Mller <lutz@users.sourceforge.net>
* src/workbook-control-gui.c: Implement reordering of sheets via
drag & drop within workbooks.
2002-09-23 Jody Goldberg <jody@gnome.org>
* src/sheet-view.c (sv_update) : see if there is a named expression that
......
2002-09-23 Jody Goldberg <jody@gnome.org>
* xml-sax-read.c (unknown_attr) : restore this and have it use
io-context.
(gnumeric_1_0_dtd) : fix.
(xml_sax_style_region_start) : Use new_default for newer versions
2002-09-06 Jody Goldberg <jody@gnome.org>
* xml-sax-read.c (xml_sax_finish_parse_wb_names_name) : convert to
......
......@@ -253,6 +253,18 @@ typedef struct {
/****************************************************************************/
static void
unknown_attr (XMLSaxParseState *state,
xmlChar const * const *attrs, char const *name)
{
g_return_if_fail (attrs != NULL);
if (state->version == GNUM_XML_LATEST)
gnm_io_warning (state->context,
_("Unexpected attribute '%s'='%s' for element of type %s."),
name, attrs[0], attrs[1]);
}
static void
xml_sax_wb (GsfXmlSAXState *gsf_state, xmlChar const **attrs)
{
......@@ -280,8 +292,9 @@ xml_sax_wb (GsfXmlSAXState *gsf_state, xmlChar const **attrs)
for (i = 0 ; GnumericVersions [i].id != NULL ; ++i )
if (strcmp (attrs[1], GnumericVersions [i].id) == 0) {
if (state->version != GNUM_XML_UNKNOWN)
xml_sax_warning (state, "Multiple version specifications. Assuming %d",
state->version);
gnm_io_warning (state->context,
_("Multiple version specifications. Assuming %d"),
state->version);
else {
state->version = GnumericVersions [i].version;
break;
......@@ -290,7 +303,7 @@ xml_sax_wb (GsfXmlSAXState *gsf_state, xmlChar const **attrs)
} else if (!strcmp (attrs[0], "xmlns:xsi")) {
} else if (!strcmp (attrs[0], "xsi:schemaLocation")) {
} else
xml_sax_unknown_attr (state, attrs, "Workbook");
unknown_attr (state, attrs, "Workbook");
}
static void
......@@ -318,7 +331,7 @@ xml_sax_wb_view (GsfXmlSAXState *gsf_state, xmlChar const **attrs)
else if (xml_sax_attr_int (attrs, "Width", &width)) ;
else if (xml_sax_attr_int (attrs, "Height", &height)) ;
else
xml_sax_unknown_attr (state, attrs, "WorkbookView");
unknown_attr (state, attrs, "WorkbookView");
if (width > 0 && height > 0)
wb_view_preferred_size (state->wb_view, width, height);
......@@ -398,7 +411,7 @@ xml_sax_sheet_start (GsfXmlSAXState *gsf_state, xmlChar const **attrs)
else if (xml_sax_attr_color (attrs, "TabColor", &color))
state->tab_color = color;
else
xml_sax_unknown_attr (state, attrs, "Sheet");
unknown_attr (state, attrs, "Sheet");
}
static void
......@@ -430,7 +443,8 @@ xml_sax_sheet_name (GsfXmlSAXState *gsf_state)
state->sheet = workbook_sheet_by_name (state->wb, content);
if (!state->sheet)
xml_sax_fatal_error (state, "SheetNameIndex reading failed");
gnumeric_io_error_string (state->context,
_("File has inconsistent SheetNameIndex element."));
} else {
state->sheet = sheet_new (state->wb, content);
workbook_sheet_attach (state->wb, state->sheet, NULL);
......@@ -477,7 +491,7 @@ xml_sax_print_margins_get_double (XMLSaxParseState *state, xmlChar const **attrs
if (xml_sax_attr_double (attrs, "Points", &points))
return points;
else if (strcmp (attrs[0], "PrefUnit"))
xml_sax_unknown_attr (state, attrs, "Margin");
unknown_attr (state, attrs, "Margin");
}
return 0.0;
}
......@@ -499,7 +513,7 @@ xml_sax_print_margins_unit (XMLSaxParseState *state, xmlChar const **attrs, Prin
else if (!strcmp (attrs[1], "in"))
pu->desired_display = UNIT_INCH;
} else
xml_sax_unknown_attr (state, attrs, "Margin");
unknown_attr (state, attrs, "Margin");
}
}
......@@ -594,7 +608,7 @@ xml_sax_selection (GsfXmlSAXState *gsf_state, xmlChar const **attrs)
if (xml_sax_attr_int (attrs, "CursorCol", &col)) ;
else if (xml_sax_attr_int (attrs, "CursorRow", &row)) ;
else
xml_sax_unknown_attr (state, attrs, "Selection");
unknown_attr (state, attrs, "Selection");
g_return_if_fail (col >= 0);
g_return_if_fail (row >= 0);
......@@ -627,7 +641,7 @@ xml_sax_sheet_layout (GsfXmlSAXState *gsf_state, xmlChar const **attrs)
sheet_get_view (state->sheet, state->wb_view),
tmp.col, tmp.row);
else
xml_sax_unknown_attr (state, attrs, "SheetLayout");
unknown_attr (state, attrs, "SheetLayout");
}
static void
......@@ -644,7 +658,7 @@ xml_sax_sheet_freezepanes (GsfXmlSAXState *gsf_state, xmlChar const **attrs)
else if (xml_sax_attr_cellpos (attrs, "UnfrozenTopLeft", &unfrozen_tl))
flags |= 2;
else
xml_sax_unknown_attr (state, attrs, "SheetLayout");
unknown_attr (state, attrs, "SheetLayout");
if (flags == 3)
sv_freeze_panes (sheet_get_view (state->sheet, state->wb_view),
......@@ -708,7 +722,7 @@ xml_sax_colrow (GsfXmlSAXState *gsf_state, xmlChar const **attrs)
else if (xml_sax_attr_int (attrs, "OutlineLevel", &dummy))
cri->outline_level = dummy;
else
xml_sax_unknown_attr (state, attrs, "ColRow");
unknown_attr (state, attrs, "ColRow");
}
}
......@@ -737,7 +751,10 @@ xml_sax_style_region_start (GsfXmlSAXState *gsf_state, xmlChar const **attrs)
g_return_if_fail (state->style_range_init == FALSE);
g_return_if_fail (state->style == NULL);
state->style = mstyle_new ();
state->style = (state->version >= GNUM_XML_V6 ||
state->version <= GNUM_XML_V2)
? mstyle_new_default ()
: mstyle_new ();
state->style_range_init =
xml_sax_attr_range (attrs, &state->style_range);
}
......@@ -800,7 +817,7 @@ xml_sax_styleregion_start (GsfXmlSAXState *gsf_state, xmlChar const **attrs)
else if (xml_sax_attr_int (attrs, "Locked", &val))
mstyle_set_content_locked (state->style, val);
else
xml_sax_unknown_attr (state, attrs, "StyleRegion");
unknown_attr (state, attrs, "StyleRegion");
}
}
......@@ -826,7 +843,7 @@ xml_sax_styleregion_font (GsfXmlSAXState *gsf_state, xmlChar const **attrs)
else if (xml_sax_attr_int (attrs, "StrikeThrough", &val))
mstyle_set_font_strike (state->style, val ? TRUE : FALSE);
else
xml_sax_unknown_attr (gsf_state, attrs, "StyleFont");
unknown_attr (state, attrs, "StyleFont");
}
}
......@@ -925,7 +942,7 @@ xml_sax_validation (GsfXmlSAXState *gsf_state, xmlChar const **attrs)
} else if (xml_sax_attr_bool (attrs, "UseDropdown", &b_dummy)) {
state->validation.use_dropdown = b_dummy;
} else
xml_sax_unknown_attr (state, attrs, "Validation");
unknown_attr (state, attrs, "Validation");
}
}
......@@ -992,7 +1009,7 @@ xml_sax_style_region_borders (GsfXmlSAXState *gsf_state, xmlChar const **attrs)
if (xml_sax_attr_color (attrs, "Color", &colour)) ;
else if (xml_sax_attr_int (attrs, "Style", &pattern)) ;
else
xml_sax_unknown_attr (state, attrs, "StyleBorder");
unknown_attr (state, attrs, "StyleBorder");
}
if (pattern >= STYLE_BORDER_NONE) {
......@@ -1032,7 +1049,7 @@ xml_sax_cell (GsfXmlSAXState *gsf_state, xmlChar const **attrs)
else if (!strcmp (attrs[0], "ValueFormat"))
value_fmt = style_format_new_XL ((char *)attrs[1], FALSE);
else
xml_sax_unknown_attr (state, attrs, "Cell");
unknown_attr (state, attrs, "Cell");
}
g_return_if_fail (col >= 0);
......@@ -1347,6 +1364,7 @@ xml_sax_name (GsfXmlSAXState *gsf_state)
/****************************************************************************/
static GsfXmlSAXNode gnumeric_1_0_dtd[] = {
GSF_XML_SAX_NODE (START, START, NULL, FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (START, WB, "gmr:Workbook", FALSE, &xml_sax_wb, NULL, 0),
GSF_XML_SAX_NODE (WB, WB_ATTRIBUTES, "gmr:Attributes", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (WB_ATTRIBUTES, WB_ATTRIBUTE, "gmr:Attribute", FALSE, NULL, &xml_sax_finish_parse_wb_attr, 0),
......@@ -1363,11 +1381,11 @@ GSF_XML_SAX_NODE (START, WB, "gmr:Workbook", FALSE, &xml_sax_wb, NULL, 0),
GSF_XML_SAX_NODE (WB, WB_SHEETNAME_INDEX, "gmr:SheetNameIndex", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (WB_SHEETNAME_INDEX, WB_SHEETNAME, "gmr:SheetName", TRUE, NULL, &xml_sax_wb_sheetname, 0),
GSF_XML_SAX_NODE (WB, WB_NAMES, "gmr:Names", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (WB_NAMES, WB_NAME, "gmr:Name", FALSE, NULL, &xml_sax_finish_parse_wb_names_name, 0),
GSF_XML_SAX_NODE (WB_NAME, WB_NAME_NAME, "gmr:name", TRUE, NULL, &xml_sax_name, 0),
GSF_XML_SAX_NODE (WB_NAME, WB_NAME_VALUE, "gmr:value", TRUE, NULL, &xml_sax_name, 1),
GSF_XML_SAX_NODE (WB_NAME, WB_NAME_POSITION, "gmr:position", TRUE, NULL, &xml_sax_name, 2),
GSF_XML_SAX_NODE (WB, WB_NAMED_EXPRS, "gmr:Names", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (WB_NAMED_EXPRS, WB_NAMED_EXPR, "gmr:Name", FALSE, NULL, &xml_sax_finish_parse_wb_names_name, 0),
GSF_XML_SAX_NODE (WB_NAMED_EXPR, WB_NAMED_EXPR_NAME, "gmr:name", TRUE, NULL, &xml_sax_name, 0),
GSF_XML_SAX_NODE (WB_NAMED_EXPR, WB_NAMED_EXPR_VALUE, "gmr:value", TRUE, NULL, &xml_sax_name, 1),
GSF_XML_SAX_NODE (WB_NAMED_EXPR, WB_NAMED_EXPR_POSITION, "gmr:position", TRUE, NULL, &xml_sax_name, 2),
GSF_XML_SAX_NODE (WB, WB_SHEETS, "gmr:Sheets", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (WB_SHEETS, SHEET, "gmr:Sheet", FALSE, &xml_sax_sheet_start, &xml_sax_sheet_end, 0),
......@@ -1375,35 +1393,37 @@ GSF_XML_SAX_NODE (START, WB, "gmr:Workbook", FALSE, &xml_sax_wb, NULL, 0),
GSF_XML_SAX_NODE (SHEET, SHEET_MAXCOL, "gmr:MaxCol", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (SHEET, SHEET_MAXROW, "gmr:MaxRow", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (SHEET, SHEET_ZOOM, "gmr:Zoom", TRUE, NULL, &xml_sax_sheet_zoom, 0),
GSF_XML_SAX_NODE (SHEET, SHEET_NAMES, "gmr:Names", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (SHEET_NAMES, SHEET_NAME, "gmr:Name", FALSE, NULL, &xml_sax_finish_parse_sheet_names_name, 0),
GSF_XML_SAX_NODE (SHEET_NAME, SHEET_NAME_NAME, "gmr:name", TRUE, NULL, &xml_sax_name, 0),
GSF_XML_SAX_NODE (SHEET_NAME, SHEET_NAME_VALUE, "gmr:value", TRUE, NULL, &xml_sax_name, 1),
GSF_XML_SAX_NODE (SHEET_NAME, SHEET_NAME_POSITION, "gmr:position", TRUE, NULL, &xml_sax_name, 2),
GSF_XML_SAX_NODE (SHEET, SHEET_NAMED_EXPRS, "gmr:Names", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (SHEET_NAMED_EXPRS, SHEET_NAMED_EXPR, "gmr:Name", FALSE, NULL, &xml_sax_finish_parse_sheet_names_name, 0),
GSF_XML_SAX_NODE (SHEET_NAMED_EXPR, SHEET_NAMED_EXPR_NAME, "gmr:name", TRUE, NULL, &xml_sax_name, 0),
GSF_XML_SAX_NODE (SHEET_NAMED_EXPR, SHEET_NAMED_EXPR_VALUE, "gmr:value", TRUE, NULL, &xml_sax_name, 1),
GSF_XML_SAX_NODE (SHEET_NAMED_EXPR, SHEET_NAMED_EXPR_POSITION, "gmr:position", TRUE, NULL, &xml_sax_name, 2),
GSF_XML_SAX_NODE (SHEET, SHEET_PRINTINFO, "gmr:PrintInformation", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (SHEET_PRINTINFO, PRINT_MARGINS, "gmr:Margins", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (PRINT_MARGINS, PRINT_MARGIN_TOP, "gmr:top", TRUE, &xml_sax_print_margins, NULL, 0),
GSF_XML_SAX_NODE (PRINT_MARGINS, PRINT_MARGIN_BOTTOM, "gmr:bottom", TRUE, &xml_sax_print_margins, NULL, 1),
GSF_XML_SAX_NODE (PRINT_MARGINS, PRINT_MARGIN_LEFT, "gmr:left", TRUE, &xml_sax_print_margins, NULL, 2),
GSF_XML_SAX_NODE (PRINT_MARGINS, PRINT_MARGIN_RIGHT, "gmr:right", TRUE, &xml_sax_print_margins, NULL, 3),
GSF_XML_SAX_NODE (PRINT_MARGINS, PRINT_MARGIN_LEFT, "gmr:left", TRUE, &xml_sax_print_margins, NULL, 2),
GSF_XML_SAX_NODE (PRINT_MARGINS, PRINT_MARGIN_RIGHT, "gmr:right", TRUE, &xml_sax_print_margins, NULL, 3),
GSF_XML_SAX_NODE (PRINT_MARGINS, PRINT_MARGIN_HEADER, "gmr:header", TRUE, &xml_sax_print_margins, NULL, 4),
GSF_XML_SAX_NODE (PRINT_MARGINS, PRINT_MARGIN_FOOTER, "gmr:footer", TRUE, &xml_sax_print_margins, NULL, 5),
GSF_XML_SAX_NODE (PRINT_MARGIN_FOOTER, PRINT_SCALE, "gmr:Scale", TRUE, &xml_sax_print_scale, NULL, 0),
GSF_XML_SAX_NODE (PRINT_SCALE, PRINT_VCENTER, "gmr:vcenter", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (PRINT_VCENTER, PRINT_HCENTER, "gmr:hcenter", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (PRINT_HCENTER, PRINT_GRID, "gmr:grid", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (PRINT_GRID, PRINT_MONO, "gmr:monochrome", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (PRINT_MONO, PRINT_AS_DRAFT, "gmr:draft", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (PRINT_AS_DRAFT, PRINT_COMMENTS, "gmr:comments", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (PRINT_COMMENTS, PRINT_TITLES, "gmr:titles", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (PRINT_TITLES, PRINT_REPEAT_TOP, "gmr:repeat_top", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (PRINT_REPEAT_TOP, PRINT_REPEAT_LEFT, "gmr:repeat_left", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (PRINT_REPEAT_LEFT, PRINT_ORDER, "gmr:order", TRUE, NULL, NULL, 0),
GSF_XML_SAX_NODE (PRINT_ORIENT, PRINT_HEADER, "gmr:Footer", TRUE, NULL, NULL, 0),
GSF_XML_SAX_NODE (PRINT_HEADER, PRINT_FOOTER, "gmr:Header", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (PRINT_FOOTER, PRINT_PAPER, "gmr:paper", TRUE, NULL, NULL, 0),
GSF_XML_SAX_NODE (SHEET_PRINTINFO, PRINT_SCALE, "gmr:Scale", TRUE, &xml_sax_print_scale, NULL, 0),
GSF_XML_SAX_NODE (SHEET_PRINTINFO, PRINT_VCENTER, "gmr:vcenter", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (SHEET_PRINTINFO, PRINT_HCENTER, "gmr:hcenter", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (SHEET_PRINTINFO, PRINT_GRID, "gmr:grid", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (SHEET_PRINTINFO, PRINT_MONO, "gmr:monochrome", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (SHEET_PRINTINFO, PRINT_AS_DRAFT, "gmr:draft", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (SHEET_PRINTINFO, PRINT_COMMENTS, "gmr:comments", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (SHEET_PRINTINFO, PRINT_TITLES, "gmr:titles", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (SHEET_PRINTINFO, PRINT_REPEAT_TOP, "gmr:repeat_top", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (SHEET_PRINTINFO, PRINT_REPEAT_LEFT, "gmr:repeat_left",FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (SHEET_PRINTINFO, PRINT_HEADER, "gmr:Footer", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (SHEET_PRINTINFO, PRINT_FOOTER, "gmr:Header", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (SHEET_PRINTINFO, PRINT_ORDER, "gmr:order", TRUE, NULL, NULL, 0),
GSF_XML_SAX_NODE (SHEET_PRINTINFO, PRINT_PAPER, "gmr:paper", TRUE, NULL, NULL, 0),
GSF_XML_SAX_NODE (SHEET_PRINTINFO, PRINT_ORIENT, "gmr:orientation",TRUE, NULL, NULL, 0),
GSF_XML_SAX_NODE (SHEET_PRINTINFO, PRINT_ONLY_STYLE, "gmr:even_if_only_styles", TRUE, NULL, NULL, 0),
GSF_XML_SAX_NODE (SHEET, SHEET_STYLES, "gmr:Styles", FALSE, NULL, NULL, 0),
GSF_XML_SAX_NODE (SHEET_STYLES, STYLE_REGION, "gmr:StyleRegion", FALSE, &xml_sax_style_region_start, &xml_sax_style_region_end, 0),
......
......@@ -119,6 +119,11 @@ struct _CustomXmlUI {
static GSList *registered_xml_uis = NULL;
enum {
TARGET_URI_LIST,
TARGET_SHEET
};
gboolean
wbcg_ui_update_begin (WorkbookControlGUI *wbcg)
{
......@@ -672,6 +677,189 @@ cb_sheet_label_button_press (GtkWidget *widget, GdkEventButton *event,
return FALSE;
}
static gint
gtk_notebook_page_num_by_label (GtkNotebook *notebook, GtkWidget *label)
{
guint i;
GtkWidget *page, *l;
g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), -1);
g_return_val_if_fail (GTK_IS_WIDGET (label), -1);
for (i = g_list_length (notebook->children); i-- > 0 ; ) {
page = gtk_notebook_get_nth_page (notebook, i);
l = gtk_notebook_get_tab_label (notebook, page);
if (label == l)
return i;
}
return -1;
}
static void
cb_sheet_label_drag_data_get (GtkWidget *widget, GdkDragContext *context,
GtkSelectionData *selection_data, guint info, guint time,
WorkbookControlGUI *wbcg)
{
SheetControlGUI *scg;
gint n_source;
GtkWidget *p_source;
g_return_if_fail (IS_WORKBOOK_CONTROL_GUI (wbcg));
n_source = gtk_notebook_page_num_by_label (wbcg->notebook, widget);
p_source = gtk_notebook_get_nth_page (wbcg->notebook, n_source);
scg = g_object_get_data (G_OBJECT (p_source), SHEET_CONTROL_KEY);
gtk_selection_data_set (selection_data, selection_data->target,
8, (void *) scg, sizeof (scg));
}
static void
cb_sheet_label_drag_data_received (GtkWidget *widget, GdkDragContext *context,
gint x, gint y, GtkSelectionData *data, guint info, guint time,
WorkbookControlGUI *wbcg)
{
GtkWidget *w_source;
gint n_source, n_dest;
Sheet *sheet;
GSList *old_order= NULL, *new_order;
Workbook *wb;
guint n, i;
g_return_if_fail (IS_WORKBOOK_CONTROL_GUI (wbcg));
w_source = gtk_drag_get_source_widget (context);
n_source = gtk_notebook_page_num_by_label (wbcg->notebook, w_source);
/*
* Is this a sheet of our workbook? If yes, we just reorder
* the sheets.
*/
if (n_source >= 0) {
/* Make a list of the current order. */
wb = wb_control_workbook (WORKBOOK_CONTROL (wbcg));
n = workbook_sheet_count (wb);
for (i = 0; i < n; i++) {
sheet = workbook_sheet_by_index (wb, i);
old_order = g_slist_append (old_order, sheet);
}
/* Make a list of the new order. */
new_order = g_slist_copy (old_order);
sheet = g_slist_nth_data (new_order, n_source);
new_order = g_slist_remove (new_order, sheet);
n_dest = gtk_notebook_page_num_by_label (wbcg->notebook,
widget);
new_order = g_slist_insert (new_order, sheet, n_dest);
/* Reorder the sheets! */
cmd_reorganize_sheets (WORKBOOK_CONTROL (wbcg), old_order,
new_order, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL);
} else {
g_return_if_fail (IS_SHEET_CONTROL_GUI (data->data));
g_warning ("Not yet implemented!");
}
}
static const char *arrow_xpm[] = {
"13 14 2 1",
" c None",
". c #000000",
" ... ",
" ... ",
" ... ",
" ... ",
" ... ",
" ... ",
" ... ",
".............",
" ........... ",
" ......... ",
" ....... ",
" ..... ",
" ... ",
" . "
};
static void
cb_sheet_label_drag_begin (GtkWidget *widget, GdkDragContext *context,
WorkbookControlGUI *wbcg)
{
GtkWidget *arrow, *image;
GdkPixbuf *pixbuf;
GdkBitmap *bitmap;
g_return_if_fail (IS_WORKBOOK_CONTROL_GUI (wbcg));
g_message ("cb_sheet_label_drag_begin");
/* Create the arrow. */
arrow = gtk_window_new (GTK_WINDOW_POPUP);
gtk_widget_realize (arrow);
pixbuf = gdk_pixbuf_new_from_xpm_data (arrow_xpm);
image = gtk_image_new_from_pixbuf (pixbuf);
gtk_widget_show (image);
gtk_container_add (GTK_CONTAINER (arrow), image);
gdk_pixbuf_render_pixmap_and_mask (pixbuf, NULL, &bitmap, 128);
g_object_unref (G_OBJECT (pixbuf));
gtk_widget_shape_combine_mask (arrow, bitmap, 0, 0);
gdk_bitmap_unref (bitmap);
g_object_ref (G_OBJECT (arrow));
gtk_object_sink (GTK_OBJECT (arrow));
g_object_set_data (G_OBJECT (widget), "arrow", arrow);
}
static void
cb_sheet_label_drag_end (GtkWidget *widget, GdkDragContext *context,
WorkbookControlGUI *wbcg)
{
GtkWidget *arrow;
g_return_if_fail (IS_WORKBOOK_CONTROL (wbcg));
/* Destroy the arrow. */
arrow = g_object_get_data (G_OBJECT (widget), "arrow");
gtk_object_destroy (GTK_OBJECT (arrow));
g_object_set_data (G_OBJECT (widget), "arrow", NULL);
}
static gboolean
cb_sheet_label_drag_motion (GtkWidget *widget, GdkDragContext *context,
gint x, gint y, guint time, WorkbookControlGUI *wbcg)
{
GtkWidget *w_source, *arrow, *window;
gint n_source, n_dest, root_x, root_y, pos_x, pos_y;
g_return_val_if_fail (IS_WORKBOOK_CONTROL_GUI (wbcg), FALSE);
g_message ("cb_sheet_label_drag_motion");
/* Make sure we are really hovering over another label. */
w_source = gtk_drag_get_source_widget (context);
n_source = gtk_notebook_page_num_by_label (wbcg->notebook, w_source);
n_dest = gtk_notebook_page_num_by_label (wbcg->notebook, widget);
if (n_source == n_dest)
return (FALSE);
/* Move the arrow to the correct position and show it. */
arrow = g_object_get_data (G_OBJECT (w_source), "arrow");
window = gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW);
gtk_window_get_position (GTK_WINDOW (window), &root_x, &root_y);
pos_x = root_x + widget->allocation.x;
pos_y = root_y + widget->allocation.y;
if (n_source < n_dest)
pos_x += widget->allocation.width;
gtk_window_move (GTK_WINDOW (arrow), pos_x, pos_y);
gtk_widget_show (arrow);
return (TRUE);
}
static void workbook_setup_sheets (WorkbookControlGUI *wbcg);
static void wbcg_menu_state_sheet_count (WorkbookControl *wbc);
......@@ -689,6 +877,9 @@ wbcg_sheet_add (WorkbookControl *wbc, SheetView *sv)
SheetControl *sc;
Sheet *sheet;
GList *ptr;
static GtkTargetEntry const drag_types[] = {
{ (char *) "GNUMERIC_SHEET", 0, TARGET_SHEET }
};
g_return_if_fail (wbcg != NULL);
......@@ -718,6 +909,24 @@ wbcg_sheet_add (WorkbookControl *wbc, SheetView *sv)
"button_press_event",
G_CALLBACK (cb_sheet_label_button_press), scg->table);
/* Drag & Drop */
gtk_drag_source_set (scg->label, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
drag_types, G_N_ELEMENTS (drag_types),
GDK_ACTION_MOVE);
gtk_drag_dest_set (scg->label, GTK_DEST_DEFAULT_ALL,
drag_types, G_N_ELEMENTS (drag_types),
GDK_ACTION_MOVE);
g_signal_connect (G_OBJECT (scg->label), "drag_begin",
G_CALLBACK (cb_sheet_label_drag_begin), wbcg);
g_signal_connect (G_OBJECT (scg->label), "drag_end",
G_CALLBACK (cb_sheet_label_drag_end), wbcg);
g_signal_connect (G_OBJECT (scg->label), "drag_data_get",
G_CALLBACK (cb_sheet_label_drag_data_get), wbcg);
g_signal_connect (G_OBJECT (scg->label), "drag_data_received",
G_CALLBACK (cb_sheet_label_drag_data_received), wbcg);
g_signal_connect (G_OBJECT (scg->label), "drag_motion",
G_CALLBACK (cb_sheet_label_drag_motion), wbcg);
gtk_widget_show (scg->label);
gtk_widget_show_all (GTK_WIDGET (scg->table));
......@@ -4673,9 +4882,9 @@ workbook_control_gui_init (WorkbookControlGUI *wbcg,
WorkbookView *optional_view, Workbook *optional_wb)
{
static GtkTargetEntry const drag_types[] = {
{ (char *)"text/uri-list", 0, 0 }
{ (char *) "text/uri-list", 0, TARGET_URI_LIST }
};
#ifdef WITH_BONOBO
BonoboUIContainer *ui_container;
#endif
......@@ -4831,9 +5040,8 @@ workbook_control_gui_init (WorkbookControlGUI *wbcg,
G_CALLBACK (cb_realize), wbcg);
/* Setup a test of Drag and Drop */
gtk_drag_dest_set (GTK_WIDGET (wbcg_toplevel (wbcg)),
GTK_DEST_DEFAULT_ALL,
drag_types, G_N_ELEMENTS (drag_types),
GDK_ACTION_COPY);
GTK_DEST_DEFAULT_ALL, drag_types, G_N_ELEMENTS (drag_types),
GDK_ACTION_COPY);
g_signal_connect (G_OBJECT (wbcg_toplevel (wbcg)),
"drag_data_received",
G_CALLBACK (wbcg_filenames_dropped), wbcg);
......
......@@ -253,6 +253,18 @@ typedef struct {
/****************************************************************************/
static void
unknown_attr (XMLSaxParseState *state,
xmlChar const * const *attrs, char const *name)
{
g_return_if_fail (attrs != NULL);
if (state->version == GNUM_XML_LATEST)
gnm_io_warning (state->context,
_("Unexpected attribute '%s'='%s' for element of type %s."),
name, attrs[0], attrs[1]);
}
static void
xml_sax_wb (GsfXmlSAXState *gsf_state, xmlChar const **attrs)
{
......@@ -280,8 +292,9 @@ xml_sax_wb (GsfXmlSAXState *gsf_state, xmlChar const **attrs)
for (i = 0 ; GnumericVersions [i].id != NULL ; ++i )
if (strcmp (attrs[1], GnumericVersions [i].id) == 0) {
if (state->version != GNUM_XML_UNKNOWN)
xml_sax_warning (state, "Multiple version specifications. Assuming %d",
state->version);
gnm_io_warning (state->context,
_("Multiple version specifications. Assuming %d"),
state->version);
else {
state->version = GnumericVersions [i].version;
break;
......@@ -290,7 +303,7 @@ xml_sax_wb (GsfXmlSAXState *gsf_state, xmlChar const **attrs)
} else if (!strcmp (attrs[0], "xmlns:xsi")) {
} else if (!strcmp (attrs[0], "xsi:schemaLocation")) {
} else
xml_sax_unknown_attr (state, attrs, "Workbook");
unknown_attr (state, attrs, "Workbook");
}
static void
......@@ -318,7 +331,7 @@ xml_sax_wb_view (GsfXmlSAXState *gsf_state, xmlChar const **attrs)
else if (xml_sax_attr_int (attrs, "Width", &width)) ;
else if (xml_sax_attr_int (attrs, "Height", &height)) ;
else
xml_sax_unknown_attr (state, attrs, "WorkbookView");
unknown_attr (state, attrs, "WorkbookView");
if (width > 0 && height > 0)
wb_view_preferred_size (state->wb_view, width, height);
......@@ -398,7 +411,7 @@ xml_sax_sheet_start (GsfXmlSAXState *gsf_state, xmlChar const **attrs)
else if (xml_sax_attr_color (attrs, "TabColor", &color))
state->tab_color = color;
else
xml_sax_unknown_attr (state, attrs, "Sheet");
unknown_attr (state, attrs, "Sheet");
}