Commit 35bab0d6 authored by Andreas J. Guelzow's avatar Andreas J. Guelzow Committed by Andreas J. Guelzow

dialog-simple-input.c (dialog_get_sheet_name) replaced by

2002-01-29  Andreas J. Guelzow <aguelzow@taliesin.ca>

	* dialog-simple-input.c (dialog_get_sheet_name) replaced by
	  sheet_name_destroy, cb_sheet_name_ok_clicked,
	  cb_sheet_name_cancel_clicked, dialog_sheet_name
	* dialogs.h (dialog_get_sheet_name) : replace with
	  dialog_sheet_name
	* sheet-rename.glade : use descriptive button ids &
	  edit label

2002-01-29  Andreas J. Guelzow <aguelzow@taliesin.ca>

	* src/workbook-control-gui.c (sheet_action_rename_sheet) : move most
	  code into dialog_sheet_name and friends
	(cb_sheet_change_name) : ditto, also rename to cb_sheet_name
parent 5cc48283
2002-01-29 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/workbook-control-gui.c (sheet_action_rename_sheet) : move most
code into dialog_sheet_name and friends
(cb_sheet_change_name) : ditto, also rename to cb_sheet_name
2002-01-28 Joshua R. Odom <jrodom@stic.net>
* src/application.c : clean up the file names to match the code.
......
......@@ -14,6 +14,7 @@ Andreas:
* Port consolidate dialog to gnome2
* Make the consolidate warning dialogs non-modal
* Allow cross-sheet consolidation
* Turn sheet-rename dialog into guru
Jody:
* Initial port to gnome2.
......
2002-01-29 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/workbook-control-gui.c (sheet_action_rename_sheet) : move most
code into dialog_sheet_name and friends
(cb_sheet_change_name) : ditto, also rename to cb_sheet_name
2002-01-28 Joshua R. Odom <jrodom@stic.net>
* src/application.c : clean up the file names to match the code.
......
2002-01-29 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/workbook-control-gui.c (sheet_action_rename_sheet) : move most
code into dialog_sheet_name and friends
(cb_sheet_change_name) : ditto, also rename to cb_sheet_name
2002-01-28 Joshua R. Odom <jrodom@stic.net>
* src/application.c : clean up the file names to match the code.
......
2002-01-29 Andreas J. Guelzow <aguelzow@taliesin.ca>
* dialog-simple-input.c (dialog_get_sheet_name) replaced by
sheet_name_destroy, cb_sheet_name_ok_clicked,
cb_sheet_name_cancel_clicked, dialog_sheet_name
* dialogs.h (dialog_get_sheet_name) : replace with
dialog_sheet_name
* sheet-rename.glade : use descriptive button ids &
edit label
2002-01-28 Jody Goldberg <jody@gnome.org>
* dialog-sheet-order.c (cb_sheet_order_destroy) : detach guru.
......
......@@ -15,6 +15,8 @@
#include <math.h>
#include <glade/glade.h>
#include <libgnome/gnome-i18n.h>
#include <sheet.h>
gboolean
dialog_choose_cols_vs_rows (WorkbookControlGUI *wbcg, const char *title,
......@@ -106,46 +108,114 @@ dialog_get_number (WorkbookControlGUI *wbcg,
return res;
}
char *
dialog_get_sheet_name (WorkbookControlGUI *wbcg, const char *current)
#define SHEET_NAME_CHANGE_DIALOG_KEY "sheet-name-change-dialog"
typedef struct {
WorkbookControlGUI *wbcg;
GtkWidget *dialog;
GtkWidget *entry;
GtkWidget *ok_button;
GtkWidget *cancel_button;
GladeXML *gui;
} SheetNameChangeState;
/**
* sheet_name_destroy:
* @window:
* @state:
*
* Destroy the dialog and associated data structures.
*
**/
static gboolean
sheet_name_destroy (GtkObject *w, SheetNameChangeState *state)
{
GladeXML *gui;
GtkDialog *dialog;
GtkWidget *entry;
char *str = NULL;
g_return_val_if_fail (w != NULL, FALSE);
g_return_val_if_fail (state != NULL, FALSE);
gui = gnumeric_glade_xml_new (wbcg, "sheet-rename.glade");
if (gui == NULL)
return NULL;
wbcg_edit_detach_guru (state->wbcg);
dialog = GTK_DIALOG (glade_xml_get_widget (gui, "dialog"));
if (dialog == NULL){
g_warning ("Cannot find the `dialog' widget in sheet-rename.glade");
gtk_object_destroy (GTK_OBJECT (gui));
return NULL;
if (state->gui != NULL) {
g_object_unref (G_OBJECT (state->gui));
state->gui = NULL;
}
entry = glade_xml_get_widget (gui, "entry");
gtk_entry_set_text (GTK_ENTRY (entry), current);
gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
state->dialog = NULL;
g_free (state);
gnumeric_editable_enters (GTK_WINDOW (dialog), GTK_EDITABLE (entry));
return FALSE;
}
switch (gnumeric_dialog_run (wbcg, dialog)){
case 1: /* cancel */
break;
case -1: /* window manager close */
gtk_object_destroy (GTK_OBJECT (gui));
return NULL;
static void
cb_sheet_name_ok_clicked (GtkWidget *button, SheetNameChangeState *state)
{
WorkbookControl *wbc = WORKBOOK_CONTROL (state->wbcg);
Sheet *sheet = wb_control_cur_sheet (wbc);
char const *new_name;
new_name = gtk_entry_get_text (GTK_ENTRY (state->entry));
cmd_rename_sheet (wbc, sheet->name_unquoted, new_name);
gtk_widget_destroy (state->dialog);
return;
}
default:
str = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
}
static void
cb_sheet_name_cancel_clicked (GtkWidget *button, SheetNameChangeState *state)
{
gtk_widget_destroy (state->dialog);
return;
}
gtk_widget_destroy (GTK_WIDGET (dialog));
gtk_object_destroy (GTK_OBJECT (gui));
void
dialog_sheet_name (WorkbookControlGUI *wbcg)
{
SheetNameChangeState *state;
WorkbookControl *wbc = WORKBOOK_CONTROL (wbcg);
Sheet *sheet = wb_control_cur_sheet (wbc);
return str;
g_return_if_fail (wbcg != NULL);
if (gnumeric_dialog_raise_if_exists (wbcg, SHEET_NAME_CHANGE_DIALOG_KEY))
return;
state = g_new (SheetNameChangeState, 1);
state->wbcg = wbcg;
state->gui = gnumeric_glade_xml_new (wbcg, "sheet-rename.glade");
g_return_if_fail (state->gui != NULL);
state->dialog = glade_xml_get_widget (state->gui, "dialog");
if (state->dialog == NULL) {
gnumeric_notice (wbcg, GTK_MESSAGE_ERROR,
_("Could not create the Sheet Name Change dialog."));
g_free (state);
return ;
}
state->ok_button = glade_xml_get_widget (state->gui, "okbutton");
gtk_signal_connect (GTK_OBJECT (state->ok_button), "clicked",
GTK_SIGNAL_FUNC (cb_sheet_name_ok_clicked),
state);
state->cancel_button = glade_xml_get_widget (state->gui, "cancelbutton");
gtk_signal_connect (GTK_OBJECT (state->cancel_button), "clicked",
GTK_SIGNAL_FUNC (cb_sheet_name_cancel_clicked),
state);
state->entry = glade_xml_get_widget (state->gui, "entry");
gtk_entry_set_text (GTK_ENTRY (state->entry), sheet->name_unquoted);
gtk_editable_select_region (GTK_EDITABLE (state->entry), 0, -1);
gnumeric_editable_enters (GTK_WINDOW (state->dialog), GTK_EDITABLE (state->entry));
gtk_signal_connect (GTK_OBJECT (state->dialog), "destroy",
GTK_SIGNAL_FUNC (sheet_name_destroy), state);
wbcg_edit_attach_guru (state->wbcg, state->dialog);
gnumeric_keyed_dialog (wbcg, GTK_WINDOW (state->dialog),
SHEET_NAME_CHANGE_DIALOG_KEY);
gtk_widget_show (state->dialog);
gtk_widget_grab_focus (state->entry);
}
......@@ -48,7 +48,7 @@ void dialog_autosave (WorkbookControlGUI *wbcg);
gboolean dialog_autosave_prompt (WorkbookControlGUI *wbcg);
void dialog_autoformat (WorkbookControlGUI *wbcg);
void dialog_consolidate (WorkbookControlGUI *wbcg, Sheet *sheet);
char *dialog_get_sheet_name (WorkbookControlGUI *wbcg, const char *name);
void dialog_sheet_name (WorkbookControlGUI *wbcg);
void dialog_sheet_order (WorkbookControlGUI *wbcg);
gboolean dialog_get_number (WorkbookControlGUI *wbcg,
const char *glade_file,
......
......@@ -24,7 +24,7 @@
<property name="visible">yes</property>
<child>
<widget class="GtkButton" id="button1">
<widget class="GtkButton" id="okbutton">
<property name="can_default">yes</property>
<property name="has_default">yes</property>
<property name="can_focus">yes</property>
......@@ -36,7 +36,7 @@
</child>
<child>
<widget class="GtkButton" id="button3">
<widget class="GtkButton" id="cancelbutton">
<property name="can_default">yes</property>
<property name="can_focus">yes</property>
<property name="visible">yes</property>
......@@ -62,7 +62,7 @@
<child>
<widget class="GtkLabel" id="label1">
<property name="label" translatable="yes">Enter new _sheet name:</property>
<property name="label" translatable="yes">Enter new name for the current _sheet:</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">no</property>
<property name="xalign">0.5</property>
......
......@@ -431,15 +431,7 @@ delete_sheet_if_possible (GtkWidget *ignored, SheetControlGUI *scg)
static void
sheet_action_rename_sheet (GtkWidget *widget, SheetControlGUI *scg)
{
SheetControl *sc = (SheetControl *) scg;
Sheet *sheet = sc->sheet;
char *new_name = dialog_get_sheet_name (scg->wbcg, sheet->name_unquoted);
if (!new_name)
return;
/* We do not care if it fails */
cmd_rename_sheet (sc->wbc, sheet->name_unquoted, new_name);
g_free (new_name);
dialog_sheet_name (scg->wbcg);
}
static void
......@@ -2025,18 +2017,9 @@ cb_insert_comment (GtkWidget *widget, WorkbookControlGUI *wbcg)
/****************************************************************************/
static void
cb_sheet_change_name (GtkWidget *widget, WorkbookControlGUI *wbcg)
cb_sheet_name (GtkWidget *widget, WorkbookControlGUI *wbcg)
{
WorkbookControl *wbc = WORKBOOK_CONTROL (wbcg);
Sheet *sheet = wb_control_cur_sheet (wbc);
char *new_name;
new_name = dialog_get_sheet_name (wbcg, sheet->name_unquoted);
if (!new_name)
return;
cmd_rename_sheet (wbc, sheet->name_unquoted, new_name);
g_free (new_name);
dialog_sheet_name (wbcg);
}
static void
......@@ -2692,7 +2675,7 @@ static GnomeUIInfo workbook_menu_edit_sheet [] = {
GNOMEUIINFO_ITEM_NONE (N_("Re_name..."),
N_("Rename the current sheet"),
cb_sheet_change_name),
cb_sheet_name),
GNOMEUIINFO_ITEM_NONE (N_("Re-_Order Sheets..."),
N_("Change the order the sheets are displayed"),
......@@ -2879,7 +2862,7 @@ static GnomeUIInfo workbook_menu_format_row [] = {
static GnomeUIInfo workbook_menu_format_sheet [] = {
GNOMEUIINFO_ITEM_NONE (N_("_Change name"),
N_("Edit the name of the current sheet"),
cb_sheet_change_name),
cb_sheet_name),
GNOMEUIINFO_ITEM_NONE (N_("Re-_Order Sheets..."),
N_("Change the order the sheets are displayed"),
cb_sheet_order),
......@@ -3290,7 +3273,7 @@ static BonoboUIVerb verbs [] = {
BONOBO_UI_UNSAFE_VERB ("RowDefaultSize",
workbook_cmd_format_row_std_height),
BONOBO_UI_UNSAFE_VERB ("SheetChangeName", cb_sheet_change_name),
BONOBO_UI_UNSAFE_VERB ("SheetChangeName", cb_sheet_name),
BONOBO_UI_UNSAFE_VERB ("SheetReorder", cb_sheet_order),
BONOBO_UI_UNSAFE_VERB ("SheetRemove", cb_sheet_remove),
......
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