[gnumeric] GUI: Restore sheet reordering by dragging.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] GUI: Restore sheet reordering by dragging.
- Date: Wed, 13 Nov 2013 01:34:32 +0000 (UTC)
commit cfc9c0ed0d9ce28ad07ec872a3be653b0680e3de
Author: Morten Welinder <terra gnome org>
Date: Tue Nov 12 20:34:00 2013 -0500
GUI: Restore sheet reordering by dragging.
This is current intra-workbook only.
ChangeLog | 5 +++++
NEWS | 1 +
src/wbc-gtk.c | 33 +++++++++++++++++++++++++++++----
src/widgets/ChangeLog | 7 +++++++
src/widgets/gnm-notebook.c | 9 ++++++++-
5 files changed, 50 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 32a9d26..84db12c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2013-11-12 Morten Welinder <terra gnome org>
+ * src/wbc-gtk.c (cb_sheet_label_button_press): Don't stop signal
+ emission.
+ (cb_bnotebook_page_reordered): New function.
+ (wbc_gtk_create_notebook_area): Attach a handler for reordering.
+
* src/mathfunc.c (gnm_cot): Work around gcc/glibc bug.
2013-11-06 Morten Welinder <terra gnome org>
diff --git a/NEWS b/NEWS
index 358676d..3256e5b 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ Morten:
* Improve accuracy of bessel functions with large non-integer alpha.
* Improve accuracy of ACOTH.
* Fix fuzzed file crash. [#708091]
+ * Restore sheet reordering by drag.
Xabier RodrÃguez Calvar:
* Fix dialog button order. [#710378]
diff --git a/src/wbc-gtk.c b/src/wbc-gtk.c
index 57b5539..18d2e74 100644
--- a/src/wbc-gtk.c
+++ b/src/wbc-gtk.c
@@ -591,7 +591,7 @@ cb_sheet_label_button_press (GtkWidget *widget, GdkEventButton *event,
gnm_notebook_set_current_page (wbcg->bnotebook, page_number);
if (event->button == 1 || NULL != wbcg->rangesel)
- return TRUE;
+ return FALSE;
if (event->button == 3) {
if ((scg_wbcg (scg))->edit_line.guru == NULL)
@@ -863,6 +863,8 @@ cb_notebook_switch_page (G_GNUC_UNUSED GtkNotebook *notebook_,
if (wbcg->snotebook == NULL)
return;
+ if (0) g_printerr ("Notebook page switch\n");
+
/* While initializing adding the sheets will trigger page changes, but
* we do not actually want to change the focus sheet for the view
*/
@@ -897,8 +899,9 @@ cb_notebook_switch_page (G_GNUC_UNUSED GtkNotebook *notebook_,
gnm_expr_entry_set_scg (wbcg->edit_line.entry, new_scg);
/*
- * Make absolutely sure the expression doesn't get 'lost', if it's invalid
- * then prompt the user and don't switch the notebook page.
+ * Make absolutely sure the expression doesn't get 'lost',
+ * if it's invalid then prompt the user and don't switch
+ * the notebook page.
*/
if (wbcg_is_editing (wbcg)) {
guint prev = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (wbcg->snotebook),
@@ -947,6 +950,23 @@ cb_bnotebook_button_press (GtkWidget *widget, GdkEventButton *event)
}
static void
+cb_bnotebook_page_reordered (GtkNotebook *notebook, GtkWidget *child,
+ int page_num, WBCGtk *wbcg)
+{
+ GtkNotebook *snotebook = GTK_NOTEBOOK (wbcg->snotebook);
+ int old = gtk_notebook_get_current_page (snotebook);
+
+ if (0) g_printerr ("Reordered %d -> %d\n", old, page_num);
+
+ if (old != page_num) {
+ Workbook *wb = wb_control_get_workbook (WORKBOOK_CONTROL (wbcg));
+ Sheet *sheet = workbook_sheet_by_index (wb, old);
+ workbook_sheet_move (sheet, page_num - old);
+ }
+}
+
+
+static void
wbc_gtk_create_notebook_area (WBCGtk *wbcg)
{
GtkWidget *placeholder;
@@ -960,8 +980,13 @@ wbc_gtk_create_notebook_area (WBCGtk *wbcg)
"switch_page",
G_CALLBACK (cb_notebook_switch_page), wbcg);
g_signal_connect (G_OBJECT (wbcg->bnotebook),
- "button-press-event", G_CALLBACK (cb_bnotebook_button_press),
+ "button-press-event",
+ G_CALLBACK (cb_bnotebook_button_press),
NULL);
+ g_signal_connect (G_OBJECT (wbcg->bnotebook),
+ "page-reordered",
+ G_CALLBACK (cb_bnotebook_page_reordered),
+ wbcg);
placeholder = gtk_paned_get_child1 (wbcg->tabs_paned);
if (placeholder)
gtk_widget_destroy (placeholder);
diff --git a/src/widgets/ChangeLog b/src/widgets/ChangeLog
index fe2eb8f..78f118b 100644
--- a/src/widgets/ChangeLog
+++ b/src/widgets/ChangeLog
@@ -1,3 +1,10 @@
+2013-11-12 Morten Welinder <terra gnome org>
+
+ * gnm-notebook.c (gnm_notebook_button_press): Let the notebook see
+ the button press unless the button claimed to handle it.
+ (gnm_notebook_insert_tab): Mark tab reorderable.
+ (gnm_notebook_init): Set notebook's group name.
+
2013-10-25 Morten Welinder <terra gnome org>
* gnm-cell-combo-view.c (gnm_cell_combo_view_popdown): Move sizing
diff --git a/src/widgets/gnm-notebook.c b/src/widgets/gnm-notebook.c
index 227e1d0..f71770f 100644
--- a/src/widgets/gnm-notebook.c
+++ b/src/widgets/gnm-notebook.c
@@ -376,7 +376,10 @@ gnm_notebook_button_press (GtkWidget *widget,
event->y < child_allocation.y + child_allocation.height) {
if (0)
g_printerr ("Button %d pressed\n", ui);
- return gtk_widget_event (child, (GdkEvent*)event);
+ if (gtk_widget_event (child, (GdkEvent*)event))
+ return TRUE;
+ else
+ break;
}
}
@@ -410,6 +413,7 @@ gnm_notebook_init (GnmNotebook *notebook)
gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_BOTTOM);
gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
+ gtk_notebook_set_group_name (GTK_NOTEBOOK (notebook), "Gnumeric");
}
GSF_CLASS (GnmNotebook, gnm_notebook,
@@ -489,6 +493,9 @@ gnm_notebook_insert_tab (GnmNotebook *nb, GtkWidget *label, int pos)
0);
gtk_notebook_insert_page (GTK_NOTEBOOK (nb), dummy_page, label, pos);
+
+ gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (nb), dummy_page,
+ TRUE);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]