Commit b6f0942a authored by Andreas J. Guelzow's avatar Andreas J. Guelzow Committed by Andreas J. Guelzow

implement adding of multiple sheets

2002-03-07  Andreas J. Guelzow <aguelzow@taliesin.ca>

	* workbook.c (workbook_sheet_reorganize) : implement adding of
	  multiple sheets

2002-03-07  Andreas J. Guelzow <aguelzow@taliesin.ca>

	* sheet-order.glade : add buttons
	* cell-sort.glade : reorder buttons
	* dialog-sheet-order.c (cb_row_inserted) : deleted
	(cb_selection_changed) : add more buttons
	(populate_sheet_list) : remove "row_inserted" handler
	(move_cb) : move wb_view_sheet_focus to cb_selection_changed
	(cb_add_clicked) : new
	(cb_duplicate_clicked) : new stub
	(cb_delete_clicked) : new stub
	(dialog_sheet_order) : add handlers to new buttons
parent de90b6f3
2002-03-07 Andreas J. Guelzow <aguelzow@taliesin.ca>
* workbook.c (workbook_sheet_reorganize) : implement adding of
multiple sheets
2002-03-06 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/sheet.c (sheet_new) : initialize sheet->index_in_wb
......
2002-03-07 Andreas J. Guelzow <aguelzow@taliesin.ca>
* workbook.c (workbook_sheet_reorganize) : implement adding of
multiple sheets
2002-03-06 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/sheet.c (sheet_new) : initialize sheet->index_in_wb
......
2002-03-07 Andreas J. Guelzow <aguelzow@taliesin.ca>
* workbook.c (workbook_sheet_reorganize) : implement adding of
multiple sheets
2002-03-06 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/sheet.c (sheet_new) : initialize sheet->index_in_wb
......
2002-03-07 Andreas J. Guelzow <aguelzow@taliesin.ca>
* sheet-order.glade : add buttons
* cell-sort.glade : reorder buttons
* dialog-sheet-order.c (cb_row_inserted) : deleted
(cb_selection_changed) : add more buttons
(populate_sheet_list) : remove "row_inserted" handler
(move_cb) : move wb_view_sheet_focus to cb_selection_changed
(cb_add_clicked) : new
(cb_duplicate_clicked) : new stub
(cb_delete_clicked) : new stub
(dialog_sheet_order) : add handlers to new buttons
2002-03-06 Jukka-Pekka Iivonen <jiivonen@hutcs.cs.hut.fi>
* dialog-solver.c: Solver rewrite related changes. Things are not
......
......@@ -24,38 +24,39 @@
<property name="visible">yes</property>
<child>
<widget class="GtkButton" id="ok_button">
<widget class="GtkButton" id="help_button">
<property name="can_default">yes</property>
<property name="has_default">yes</property>
<property name="can_focus">yes</property>
<property name="visible">yes</property>
<property name="label">gtk-ok</property>
<property name="label">gtk-help</property>
<property name="use_stock">yes</property>
<property name="use_underline">yes</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="cancel_button">
<widget class="GtkButton" id="ok_button">
<property name="can_default">yes</property>
<property name="has_default">yes</property>
<property name="can_focus">yes</property>
<property name="visible">yes</property>
<property name="label">gtk-cancel</property>
<property name="label">gtk-ok</property>
<property name="use_stock">yes</property>
<property name="use_underline">yes</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="help_button">
<widget class="GtkButton" id="cancel_button">
<property name="can_default">yes</property>
<property name="can_focus">yes</property>
<property name="visible">yes</property>
<property name="label">gtk-help</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">yes</property>
<property name="use_underline">yes</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
......
......@@ -31,6 +31,9 @@ typedef struct {
GtkListStore *model;
GtkWidget *up_btn;
GtkWidget *down_btn;
GtkWidget *add_btn;
GtkWidget *duplicate_btn;
GtkWidget *delete_btn;
GtkWidget *ok_btn;
GtkWidget *cancel_btn;
......@@ -101,7 +104,12 @@ cb_selection_changed (GtkTreeSelection *ignored, SheetManager *state)
GtkTreeIter iter;
GtkTreeIter this_iter;
gint row;
Sheet *sheet;
GtkTreeSelection *selection = gtk_tree_view_get_selection (state->sheet_list);
gtk_widget_set_sensitive (state->add_btn, TRUE);
gtk_widget_set_sensitive (state->duplicate_btn, FALSE);
gtk_widget_set_sensitive (state->delete_btn, FALSE);
if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) {
gtk_widget_set_sensitive (state->up_btn, FALSE);
......@@ -114,27 +122,15 @@ cb_selection_changed (GtkTreeSelection *ignored, SheetManager *state)
row = location_of_iter (&iter, state->model);
gtk_widget_set_sensitive (state->down_btn,
gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (state->model),
&this_iter, NULL, row+1));
}
static void
cb_row_inserted (GtkTreeModel *tree_model,
GtkTreePath *path,
GtkTreeIter *iter,
SheetManager *state)
{
GValue value = {0, };
Sheet *sheet;
gtk_tree_model_get_value (GTK_TREE_MODEL (state->model),
iter, SHEET_POINTER, &value);
sheet = g_value_get_pointer (&value);
g_value_unset (&value);
gtk_tree_model_iter_nth_child
(GTK_TREE_MODEL (state->model),
&this_iter, NULL, row+1));
if (sheet != NULL) {
puts (sheet->name_unquoted);
}
gtk_tree_model_get (GTK_TREE_MODEL (state->model), &iter,
SHEET_POINTER, &sheet, -1);
if (sheet != NULL)
wb_view_sheet_focus (
wb_control_view (WORKBOOK_CONTROL (state->wbcg)), sheet);
}
/* Add all of the sheets to the sheet_list */
......@@ -191,9 +187,6 @@ populate_sheet_list (SheetManager *state)
g_signal_connect (selection,
"changed",
G_CALLBACK (cb_selection_changed), state);
g_signal_connect (GTK_TREE_MODEL (state->model),
"row_inserted",
G_CALLBACK (cb_row_inserted), state);
gtk_container_add (GTK_CONTAINER (scrolled), GTK_WIDGET (state->sheet_list));
}
......@@ -231,10 +224,6 @@ move_cb (SheetManager *state, gint direction)
g_free (name);
g_free (new_name);
wb_view_sheet_focus (
wb_control_view (WORKBOOK_CONTROL (state->wbcg)),
sheet);
/* this is a little hack-ish, but we need to refresh the buttons */
cb_selection_changed (NULL, state);
}
......@@ -242,6 +231,34 @@ move_cb (SheetManager *state, gint direction)
static void cb_up (GtkWidget *w, SheetManager *state) { move_cb (state, -1); }
static void cb_down (GtkWidget *w, SheetManager *state) { move_cb (state, 1); }
static void
cb_add_clicked (GtkWidget *ignore, SheetManager *state)
{
GtkTreeIter iter;
GtkTreeSelection *selection = gtk_tree_view_get_selection (state->sheet_list);
gtk_list_store_append (state->model, &iter);
gtk_list_store_set (state->model, &iter,
SHEET_NAME, _("<new>"),
SHEET_NEW_NAME, "",
SHEET_POINTER, NULL,
IS_EDITABLE_COLUMN, TRUE,
-1);
gtk_tree_selection_select_iter (selection, &iter);
}
static void
cb_duplicate_clicked (GtkWidget *ignore, SheetManager *state)
{
g_warning ("'Duplicate' not implemented\n");
}
static void
cb_delete_clicked (GtkWidget *ignore, SheetManager *state)
{
g_warning ("'Remove' not implemented\n");
}
static void
cb_cancel_clicked (GtkWidget *ignore, SheetManager *state)
{
......@@ -282,6 +299,8 @@ cb_ok_clicked (GtkWidget *ignore, SheetManager *state)
}
new_order = g_slist_reverse (new_order);
new_names = g_slist_reverse (new_names);
changed_names = g_slist_reverse (changed_names);
this_new = new_order;
this_old = state->old_order;
......@@ -343,12 +362,17 @@ dialog_sheet_order (WorkbookControlGUI *wbcg)
state->dialog = glade_xml_get_widget (gui, "sheet-order-dialog");
state->up_btn = glade_xml_get_widget (gui, "up_button");
state->down_btn = glade_xml_get_widget (gui, "down_button");
state->add_btn = glade_xml_get_widget (gui, "add_button");
state->duplicate_btn = glade_xml_get_widget (gui, "duplicate_button");
state->delete_btn = glade_xml_get_widget (gui, "delete_button");
state->ok_btn = glade_xml_get_widget (gui, "ok_button");
state->cancel_btn = glade_xml_get_widget (gui, "cancel_button");
state->old_order = NULL;
gtk_button_stock_alignment_set (GTK_BUTTON (state->up_btn), 0., .5, 0., 0.);
gtk_button_stock_alignment_set (GTK_BUTTON (state->down_btn), 0., .5, 0., 0.);
gtk_button_stock_alignment_set (GTK_BUTTON (state->add_btn), 0., .5, 0., 0.);
gtk_button_stock_alignment_set (GTK_BUTTON (state->delete_btn), 0., .5, 0., 0.);
populate_sheet_list (state);
......@@ -358,6 +382,15 @@ dialog_sheet_order (WorkbookControlGUI *wbcg)
g_signal_connect (G_OBJECT (state->down_btn),
"clicked",
G_CALLBACK (cb_down), state);
g_signal_connect (G_OBJECT (state->add_btn),
"clicked",
G_CALLBACK (cb_add_clicked), state);
g_signal_connect (G_OBJECT (state->duplicate_btn),
"clicked",
G_CALLBACK (cb_duplicate_clicked), state);
g_signal_connect (G_OBJECT (state->delete_btn),
"clicked",
G_CALLBACK (cb_delete_clicked), state);
g_signal_connect (G_OBJECT (state->ok_btn),
"clicked",
G_CALLBACK (cb_ok_clicked), state);
......
......@@ -22,7 +22,7 @@
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area1">
<property name="layout_style">GTK_BUTTONBOX_SPREAD</property>
<property name="layout_style">GTK_BUTTONBOX_START</property>
<property name="spacing">8</property>
<property name="visible">yes</property>
......@@ -69,21 +69,18 @@
</child>
<child>
<widget class="GtkVBox" id="vbox1">
<widget class="GtkTable" id="maintable">
<property name="border_width">5</property>
<property name="homogeneous">no</property>
<property name="spacing">0</property>
<property name="row_spacing">4</property>
<property name="column_spacing">4</property>
<property name="n-rows">1</property>
<property name="n-columns">2</property>
<property name="visible">yes</property>
<child>
<widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkScrolledWindow" id="scrolled">
<property name="width_request">100</property>
<property name="width_request">200</property>
<property name="height_request">120</property>
<property name="visible">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
......@@ -92,26 +89,27 @@
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_padding">0</property>
<property name="y_padding">0</property>
<property name="x_options">expand|fill</property>
<property name="y_options">expand|fill</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="yalign">1</property>
<property name="xscale">1</property>
<property name="yscale">0</property>
<child>
<widget class="GtkTable" id="sheet_order_buttons_table">
<property name="border_width">0</property>
<property name="homogeneous">yes</property>
<property name="row_spacing">4</property>
<property name="column_spacing">4</property>
<property name="n-rows">6</property>
<property name="n-columns">1</property>
<property name="visible">yes</property>
<child>
<widget class="GtkButton" id="up_button">
......@@ -122,49 +120,109 @@
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_padding">0</property>
<property name="y_padding">0</property>
<property name="x_options">expand|fill</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="xscale">1</property>
<property name="yscale">0</property>
<child>
<widget class="GtkButton" id="down_button">
<property name="visible">True</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-go-down</property>
<property name="use_stock">True</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_padding">0</property>
<property name="y_padding">0</property>
<property name="x_options">expand|fill</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
<child>
<widget class="GtkButton" id="add_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-add</property>
<property name="use_stock">True</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_padding">0</property>
<property name="y_padding">0</property>
<property name="x_options">expand|fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkButton" id="duplicate_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label">_Duplicate</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_padding">0</property>
<property name="y_padding">0</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="delete_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-remove</property>
<property name="use_stock">True</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_padding">0</property>
<property name="y_padding">0</property>
<property name="x_options">expand|fill</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_padding">0</property>
<property name="y_padding">0</property>
<property name="x_options">fill</property>
<property name="y_options">expand|fill</property>
</packing>
</child>
</widget>
<packing>
......@@ -173,6 +231,7 @@
<property name="fill">yes</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">4</property>
......
......@@ -1271,7 +1271,6 @@ workbook_sheet_reorganize (WorkbookControl *wbc,
the_sheets = changed_names;
while (the_names) {
Sheet *sheet = the_sheets->data;
if (sheet == NULL) {
char *name = the_names->data;
Sheet *a_new_sheet ;
......@@ -1284,41 +1283,47 @@ workbook_sheet_reorganize (WorkbookControl *wbc,
if (free_name)
g_free (name);
workbook_sheet_attach (wb, a_new_sheet, NULL);
sheet_set_dirty (a_new_sheet, TRUE);
*new_sheets = g_slist_prepend ( *new_sheets, a_new_sheet);
*new_sheets = g_slist_prepend (*new_sheets, a_new_sheet);
}
the_names = the_names->next;
the_sheets = the_sheets->next;
}
*new_sheets = g_slist_reverse (*new_sheets);
new_sheet = *new_sheets;
new_sheet = *new_sheets = g_slist_reverse (*new_sheets);
}
/* reordering */
this_sheet = new_order;
while (this_sheet) {
gboolean an_old_sheet = TRUE;
Sheet *sheet = this_sheet->data;
if (new_sheets && sheet == NULL) {
sheet = new_sheet->data;
new_sheet = new_sheet->next;
an_old_sheet = FALSE;
}
if (sheet != NULL) {
old_pos = sheet->index_in_wb;
if (new_pos != old_pos) {
int max_pos = MAX (old_pos, new_pos);
int min_pos = MIN (old_pos, new_pos);
g_ptr_array_remove_index (wb->sheets, old_pos);
g_ptr_array_insert (wb->sheets, sheet, new_pos);
for (; max_pos >= min_pos ; max_pos--) {
Sheet *sheet = g_ptr_array_index (wb->sheets, max_pos);
sheet->index_in_wb = max_pos;
}
WORKBOOK_FOREACH_CONTROL (wb, view, control,
wb_control_sheet_move (control,
sheet, new_pos););
sheet_set_dirty (sheet, TRUE);
if (an_old_sheet)
sheet_set_dirty (sheet, TRUE);
}
new_pos++;
}
this_sheet = this_sheet->next;
}
if (new_order)
workbook_sheet_index_update (wb, 0);
return FALSE;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment