[gnumeric] Allow the sheet object name to be specified. [#596545]
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnumeric] Allow the sheet object name to be specified. [#596545]
- Date: Sun, 27 Dec 2009 09:26:50 +0000 (UTC)
commit 4281a59477664c20ca8aaad8b95eb14211961c23
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Sun Dec 27 02:26:15 2009 -0700
Allow the sheet object name to be specified. [#596545]
2009-12-27 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/sheet-object.c (cb_so_size_position): use g_return_if_fail
* src/commands.h (cmd_so_rename): new
* src/commands.c (cmd_so_rename): new
(cmd_so_rename_*): new
2009-12-27 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-sheetobject-size.c (dialog_so_size_button_sensitivity):
check for changed name
(cb_dialog_so_size_destroy): handle name field
(cb_dialog_so_size_apply_clicked): handle name
(cb_dialog_so_size_name_changed): new
(dialog_so_size): handle name entry
* sheetobject-size.glade: Enable name entry
ChangeLog | 7 +++
NEWS | 1 +
src/commands.c | 69 ++++++++++++++++++++++++++++
src/commands.h | 23 ++++++---
src/dialogs/ChangeLog | 10 ++++
src/dialogs/dialog-sheetobject-size.c | 80 +++++++++++++++++++++++++++-----
src/dialogs/sheetobject-size.glade | 4 +-
src/sheet-object.c | 4 +-
8 files changed, 173 insertions(+), 25 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7163a29..03ca506 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-12-27 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * src/sheet-object.c (cb_so_size_position): use g_return_if_fail
+ * src/commands.h (cmd_so_rename): new
+ * src/commands.c (cmd_so_rename): new
+ (cmd_so_rename_*): new
+
2009-12-26 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/sheet-object.c (cb_so_size_position): new
diff --git a/NEWS b/NEWS
index cfe78b6..84abfb0 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ Andreas:
* Fix tab behaviour. [#388344]
* Print sheet widget objects. [#144787]
* Allow sheet object sizes to be specified via a dialog.
+ * Allow the sheet object name to be specified. [#596545]
Jean
* Fix import export of line type in scatter plots. [#605043]
diff --git a/src/commands.c b/src/commands.c
index 59a5bd1..d53ce62 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -7600,3 +7600,72 @@ cmd_autofilter_add_remove (WorkbookControl *wbc)
}
/******************************************************************/
+
+
+#define CMD_SO_RENAME_TYPE (cmd_so_rename_get_type ())
+#define CMD_SO_RENAME(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CMD_SO_RENAME_TYPE, CmdSORename))
+
+typedef struct {
+ GnmCommand cmd;
+ SheetObject *so;
+ char *old_name;
+ char *new_name;
+} CmdSORename;
+
+MAKE_GNM_COMMAND (CmdSORename, cmd_so_rename, NULL)
+
+static gboolean
+cmd_so_rename_redo (GnmCommand *cmd, G_GNUC_UNUSED WorkbookControl *wbc)
+{
+ CmdSORename *me = CMD_SO_RENAME (cmd);
+
+ sheet_object_set_name (me->so, me->new_name);
+
+ return FALSE;
+}
+
+static gboolean
+cmd_so_rename_undo (GnmCommand *cmd, G_GNUC_UNUSED WorkbookControl *wbc)
+{
+ CmdSORename *me = CMD_SO_RENAME (cmd);
+
+ sheet_object_set_name (me->so, me->old_name);
+
+ return FALSE;
+}
+
+static void
+cmd_so_rename_finalize (GObject *cmd)
+{
+ CmdSORename *me = CMD_SO_RENAME (cmd);
+
+ g_free (me->old_name);
+ me->old_name = NULL;
+
+ g_free (me->new_name);
+ me->new_name = NULL;
+
+ gnm_command_finalize (cmd);
+}
+
+gboolean
+cmd_so_rename (WorkbookControl *wbc,
+ SheetObject *so,
+ char const *new_name)
+{
+ CmdSORename *me;
+
+ g_return_val_if_fail (IS_WORKBOOK_CONTROL (wbc), TRUE);
+
+ me = g_object_new (CMD_SO_RENAME_TYPE, NULL);
+ me->cmd.sheet = sheet_object_get_sheet (so);
+ me->cmd.size = 1;
+ me->cmd.cmd_descriptor = g_strdup (_("Set Object Name"));
+ me->so = so;
+ g_object_get (G_OBJECT (so), "name", &(me->old_name), NULL);
+ me->new_name = g_strdup (new_name);
+
+ return gnm_command_push_undo (wbc, G_OBJECT (me));
+}
+
+/******************************************************************/
diff --git a/src/commands.h b/src/commands.h
index f6b79fa..95c442c 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -148,14 +148,8 @@ gboolean cmd_objects_move (WorkbookControl *wbc,
gboolean cmd_object_format (WorkbookControl *wbc, SheetObject *so,
gpointer orig_style, char *orig_text,
PangoAttrList *orig_attr);
-
-gboolean cmd_reorganize_sheets (WorkbookControl *wbc,
- WorkbookSheetState *old_state,
- Sheet *undo_sheet);
-
-gboolean cmd_resize_sheets (WorkbookControl *wbc,
- GSList *sheets,
- int cols, int rows);
+gboolean cmd_so_rename (WorkbookControl *wbc, SheetObject *so,
+ char const *new_name);
gboolean cmd_so_graph_config (WorkbookControl *wbc, SheetObject *sog,
GObject *n_graph, GObject *o_graph);
@@ -203,6 +197,19 @@ gboolean cmd_so_set_adjustment (WorkbookControl *wbc, SheetObject *so,
/********************************************************************************/
+gboolean cmd_reorganize_sheets (WorkbookControl *wbc,
+ WorkbookSheetState *old_state,
+ Sheet *undo_sheet);
+
+gboolean cmd_resize_sheets (WorkbookControl *wbc,
+ GSList *sheets,
+ int cols, int rows);
+
+
+
+
+/********************************************************************************/
+
G_END_DECLS
#endif /* _GNM_COMMANDS_H_ */
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index a0e214e..e4dc3e4 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,13 @@
+2009-12-27 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * dialog-sheetobject-size.c (dialog_so_size_button_sensitivity):
+ check for changed name
+ (cb_dialog_so_size_destroy): handle name field
+ (cb_dialog_so_size_apply_clicked): handle name
+ (cb_dialog_so_size_name_changed): new
+ (dialog_so_size): handle name entry
+ * sheetobject-size.glade: Enable name entry
+
2009-12-26 Andreas J. Guelzow <aguelzow pyrshep ca>
* Makefile.am: add dialog-sheetobject-size.c and
diff --git a/src/dialogs/dialog-sheetobject-size.c b/src/dialogs/dialog-sheetobject-size.c
index 24b8d36..d0058e1 100644
--- a/src/dialogs/dialog-sheetobject-size.c
+++ b/src/dialogs/dialog-sheetobject-size.c
@@ -59,12 +59,15 @@ typedef struct {
GtkSpinButton *wspin;
GtkWidget *hpoints;
GtkSpinButton *hspin;
+ GtkEntry *nameentry;
SheetObject *so;
SheetObjectAnchor *old_anchor;
SheetObjectAnchor *active_anchor;
double coords[4];
+ gchar *old_name;
gboolean so_needs_restore;
+ gboolean so_name_changed;
} SOSizeState;
static void
@@ -81,8 +84,12 @@ cb_dialog_so_size_value_changed_update_points (GtkSpinButton *spinbutton,
static void
dialog_so_size_button_sensitivity (SOSizeState *state)
{
- gtk_widget_set_sensitive (state->ok_button, state->so_needs_restore);
- gtk_widget_set_sensitive (state->apply_button, state->so_needs_restore);
+ gtk_widget_set_sensitive
+ (state->ok_button,
+ state->so_needs_restore || state->so_name_changed);
+ gtk_widget_set_sensitive
+ (state->apply_button,
+ state->so_needs_restore || state->so_name_changed);
}
static void
@@ -92,6 +99,7 @@ cb_dialog_so_size_destroy (SOSizeState *state)
sheet_object_set_anchor (state->so, state->old_anchor);
g_free (state->old_anchor);
g_free (state->active_anchor);
+ g_free (state->old_name);
if (state->so!= NULL)
g_object_unref (G_OBJECT (state->so));
if (state->gui != NULL)
@@ -142,7 +150,8 @@ cb_dialog_so_size_value_changed (G_GNUC_UNUSED GtkSpinButton *spinbutton,
else
new_coords[1] = new_coords[3] + new_height;
- scg_object_coords_to_anchor (state->scg, new_coords, state->active_anchor);
+ scg_object_coords_to_anchor (state->scg, new_coords,
+ state->active_anchor);
}
sheet_object_set_anchor (state->so, state->active_anchor);
@@ -154,8 +163,11 @@ static void
dialog_so_size_load (SOSizeState *state)
{
g_free (state->old_anchor);
- state->old_anchor = sheet_object_anchor_dup (sheet_object_get_anchor (state->so));
- scg_object_anchor_to_coords (state->scg, state->old_anchor, state->coords);
+ state->old_anchor = sheet_object_anchor_dup
+ (sheet_object_get_anchor (state->so));
+ scg_object_anchor_to_coords (state->scg,
+ state->old_anchor,
+ state->coords);
state->so_needs_restore = FALSE;
}
@@ -164,15 +176,27 @@ static void
cb_dialog_so_size_apply_clicked (G_GNUC_UNUSED GtkWidget *button,
SOSizeState *state)
{
- if (!state->so_needs_restore)
- return;
+ char const *name;
+
+ if (state->so_needs_restore) {
+ sheet_object_set_anchor (state->so, state->old_anchor);
+ if (!cmd_objects_move (WORKBOOK_CONTROL (state->wbcg),
+ g_slist_prepend (NULL, state->so),
+ g_slist_prepend
+ (NULL, sheet_object_anchor_dup
+ (state->active_anchor)),
+ FALSE, _("Resize Object")))
+ dialog_so_size_load (state);
+ }
- sheet_object_set_anchor (state->so, state->old_anchor);
- if (!cmd_objects_move (WORKBOOK_CONTROL (state->wbcg), g_slist_prepend (NULL, state->so),
- g_slist_prepend
- (NULL, sheet_object_anchor_dup (state->active_anchor)),
- FALSE, _("Resize Object")))
- dialog_so_size_load (state);
+ name = gtk_entry_get_text (state->nameentry);
+ if (name == NULL)
+ name = "";
+ if (strcmp (name, state->old_name) != 0)
+ state->so_name_changed
+ = cmd_so_rename (WORKBOOK_CONTROL (state->wbcg),
+ state->so,
+ (*name == '\0') ? NULL : name);
dialog_so_size_button_sensitivity (state);
@@ -188,6 +212,21 @@ cb_dialog_so_size_ok_clicked (GtkWidget *button, SOSizeState *state)
return;
}
+static gboolean
+cb_dialog_so_size_name_changed (GtkEntry *entry,
+ GdkEventFocus *event,
+ SOSizeState *state)
+{
+ char const *name = gtk_entry_get_text (entry);
+ if (name == NULL)
+ name = "";
+ state->so_name_changed
+ = (strcmp (name, state->old_name) != 0);
+ dialog_so_size_button_sensitivity (state);
+ return FALSE;
+}
+
+
void
dialog_so_size (WBCGtk *wbcg, GObject *so)
{
@@ -214,7 +253,22 @@ dialog_so_size (WBCGtk *wbcg, GObject *so)
state->so = SHEET_OBJECT (so);
g_object_ref (so);
+
+ state->nameentry = GTK_ENTRY (glade_xml_get_widget (state->gui, "name-entry"));
state->old_anchor = NULL;
+ state->old_name = NULL;
+ g_object_get (so, "name", &state->old_name, NULL);
+ if (state->old_name == NULL)
+ state->old_name = g_strdup ("");
+ gtk_entry_set_text (state->nameentry, state->old_name);
+ state->so_name_changed = FALSE;
+ g_signal_connect (G_OBJECT (state->nameentry),
+ "focus-out-event",
+ G_CALLBACK (cb_dialog_so_size_name_changed),
+ state);
+
+
+
state->wpoints = GTK_WIDGET (glade_xml_get_widget (state->gui, "w-pts-label"));
state->wspin = GTK_SPIN_BUTTON (glade_xml_get_widget (state->gui, "w-spin"));
diff --git a/src/dialogs/sheetobject-size.glade b/src/dialogs/sheetobject-size.glade
index c21ab72..7fae02c 100644
--- a/src/dialogs/sheetobject-size.glade
+++ b/src/dialogs/sheetobject-size.glade
@@ -153,7 +153,7 @@
<child>
<widget class="GtkLabel" id="name">
<property name="visible">True</property>
- <property name="sensitive">False</property>
+ <property name="sensitive">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Name:</property>
<property name="use_underline">True</property>
@@ -168,7 +168,7 @@
<child>
<widget class="GtkEntry" id="name-entry">
<property name="visible">True</property>
- <property name="sensitive">False</property>
+ <property name="sensitive">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">This name is used by some plugins that provide programmability to address this object. Most users will not need to set this name. </property>
<property name="invisible_char">•</property>
diff --git a/src/sheet-object.c b/src/sheet-object.c
index d4c5ba4..1723854 100644
--- a/src/sheet-object.c
+++ b/src/sheet-object.c
@@ -66,8 +66,8 @@ static GQuark sov_container_quark;
static void
cb_so_size_position (SheetObject *so, SheetControl *sc)
{
- g_return_val_if_fail (IS_SHEET_CONTROL_GUI (sc), NULL);
- dialog_so_size (((SheetControlGUI *)sc)->wbcg, so);
+ g_return_if_fail (IS_SHEET_CONTROL_GUI (sc));
+ dialog_so_size (((SheetControlGUI *)sc)->wbcg, G_OBJECT (so));
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]