gnumeric r16977 - in trunk: . src
- From: mortenw svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r16977 - in trunk: . src
- Date: Wed, 26 Nov 2008 23:52:55 +0000 (UTC)
Author: mortenw
Date: Wed Nov 26 23:52:55 2008
New Revision: 16977
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16977&view=rev
Log:
2008-11-26 Morten Welinder <terra gnome org>
Enable drag of whole sheets to other apps. #523033, initial patch
by Lutz Mueller.
* src/wbc-gtk.c (cb_sheet_label_drag_data_get): Use
scg_drag_data_get.
(wbcg_sheet_add): Add more drag types.
* src/sheet-control-gui.c (scg_drag_send_text): New function.
(scg_drag_data_get): Protect against null scg->selected_objects.
(scg_drag_data_get): Handle UTF8_STRING.
Modified:
trunk/ChangeLog
trunk/NEWS
trunk/src/sheet-control-gui.c
trunk/src/wbc-gtk.c
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Wed Nov 26 23:52:55 2008
@@ -21,6 +21,9 @@
Jody:
* Display top-left when selecting a rel ref to a merged region.
+Lutz Mueller:
+ * Enable drag of whole sheets to other applications. [#523033]
+
Morten:
* Fix XLS import crash. [#557077]
* Fix problem with auto filter after column insert. [#557237]
Modified: trunk/src/sheet-control-gui.c
==============================================================================
--- trunk/src/sheet-control-gui.c (original)
+++ trunk/src/sheet-control-gui.c Wed Nov 26 23:52:55 2008
@@ -3569,11 +3569,29 @@
cellregion_unref (content);
}
+static void
+scg_drag_send_text (SheetControlGUI *scg, GtkSelectionData *sd)
+{
+ Sheet *sheet = scg_sheet (scg);
+ Workbook *wb = sheet->workbook;
+ GnmRange range = sheet_get_extent (sheet, TRUE);
+ GnmCellRegion *reg = clipboard_copy_range (sheet, &range);
+ GString *s = cellregion_to_string (reg, TRUE, workbook_date_conv (wb));
+
+ cellregion_unref (reg);
+ if (!s)
+ return;
+ gtk_selection_data_set (sd, sd->target, 8, s->str, s->len);
+ g_string_free (s, TRUE);
+}
+
void
scg_drag_data_get (SheetControlGUI *scg, GtkSelectionData *selection_data)
{
gchar *target_name = gdk_atom_name (selection_data->target);
- GSList *objects = go_hash_keys (scg->selected_objects);
+ GSList *objects = scg->selected_objects
+ ? go_hash_keys (scg->selected_objects)
+ : NULL;
if (strcmp (target_name, "GNUMERIC_SAME_PROC") == 0)
/* Set dummy selection for process internal dnd */
@@ -3586,6 +3604,8 @@
scg_drag_send_graph (scg, selection_data, objects, target_name);
else if (strncmp (target_name, "image/", 6) == 0)
scg_drag_send_image (scg, selection_data, objects, target_name);
+ else if (strcmp (target_name, "UTF8_STRING") == 0)
+ scg_drag_send_text (scg, selection_data);
g_free (target_name);
g_slist_free (objects);
Modified: trunk/src/wbc-gtk.c
==============================================================================
--- trunk/src/wbc-gtk.c (original)
+++ trunk/src/wbc-gtk.c Wed Nov 26 23:52:55 2008
@@ -520,8 +520,7 @@
SheetControlGUI *scg = get_scg (widget);
g_return_if_fail (IS_SHEET_CONTROL_GUI (scg));
- gtk_selection_data_set (selection_data, selection_data->target,
- 8, (void *) scg, sizeof (scg));
+ scg_drag_data_get (scg, selection_data);
}
static void
@@ -823,7 +822,7 @@
/* if we are not selecting a range for an expression update */
sheet = wbcg_focus_cur_scg (wbcg);
- if (sheet != wb_control_cur_sheet (WORKBOOK_CONTROL (wbcg))) {
+ if (sheet != wbcg_cur_sheet (wbcg)) {
wbcg_update_menu_feedback (wbcg, sheet);
sheet_flag_status_update_range (sheet, NULL);
sheet_update (sheet);
@@ -1095,7 +1094,14 @@
wbcg_sheet_add (WorkbookControl *wbc, SheetView *sv)
{
static GtkTargetEntry const drag_types[] = {
- { (char *) "GNUMERIC_SHEET", GTK_TARGET_SAME_APP, TARGET_SHEET }
+ { (char *)"GNUMERIC_SHEET", GTK_TARGET_SAME_APP, TARGET_SHEET },
+ { (char *)"UTF8_STRING", 0, 0 },
+ { (char *)"image/svg+xml", 0, 0 },
+ { (char *)"image/x-wmf", 0, 0 },
+ { (char *)"image/x-emf", 0, 0 },
+ { (char *)"image/png", 0, 0 },
+ { (char *)"image/jpeg", 0, 0 },
+ { (char *)"image/bmp", 0, 0 }
};
WBCGtk *wbcg = (WBCGtk *)wbc;
@@ -1824,8 +1830,7 @@
*/
if (wbcg->snotebook) {
wbcg_focus_cur_scg (wbcg);
- wbcg_update_menu_feedback (wbcg,
- wb_control_cur_sheet (WORKBOOK_CONTROL (wbcg)));
+ wbcg_update_menu_feedback (wbcg, wbcg_cur_sheet (wbcg));
}
}
@@ -2006,7 +2011,7 @@
gtk_widget_show (GTK_WIDGET (wbcg_toplevel (wbcg)));
/* rehide headers if necessary */
- if (NULL != scg && wb_control_cur_sheet (WORKBOOK_CONTROL (wbcg)))
+ if (NULL != scg && wbcg_cur_sheet (wbcg))
scg_adjust_preferences (scg);
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]