[gnumeric] Allow sheet object position to be adjusted via a dialog.
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnumeric] Allow sheet object position to be adjusted via a dialog.
- Date: Mon, 28 Dec 2009 04:14:26 +0000 (UTC)
commit e3d0bee1d0b5dd62f04af4aab0649d4b167d92a4
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Sun Dec 27 21:13:22 2009 -0700
Allow sheet object position to be adjusted via a dialog.
2009-12-28 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-sheetobject-size.c (dialog_so_size_button_sensitivity):
handle position
(cb_dialog_so_size_destroy): ditto
(cb_dialog_so_size_value_changed): ditto
(dialog_so_size_load): ditto
(cb_dialog_so_size_apply_clicked): ditto
(dialog_so_size): ditto
* sheetobject-size.glade: add position section
2009-12-27 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/sheet-object.c (sheet_object_populate_menu_real): change "Si_ze"
to "Size _& Position"
ChangeLog | 5 +
NEWS | 2 +-
src/dialogs/ChangeLog | 11 ++
src/dialogs/dialog-sheetobject-size.c | 78 ++++++++++----
src/dialogs/sheetobject-size.glade | 190 +++++++++++++++++++++++++++++++--
src/sheet-object.c | 2 +-
6 files changed, 255 insertions(+), 33 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 709b5b2..37d430b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2009-12-27 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * src/sheet-object.c (sheet_object_populate_menu_real): change "Si_ze"
+ to "Size _& Position"
+
+2009-12-27 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* src/sheet-object.c (cb_so_size_position): make sure we only have one
guru active
(sheet_object_get_editor): ditto
diff --git a/NEWS b/NEWS
index f53149b..1f6b6c6 100644
--- a/NEWS
+++ b/NEWS
@@ -9,7 +9,7 @@ Andreas:
* Write series labels to ODF files.
* Fix tab behaviour. [#388344]
* Print sheet widget objects. [#144787]
- * Allow sheet object sizes to be specified via a dialog.
+ * Allow sheet object size and position to be specified via a dialog.
* Allow the sheet object name to be specified. [#596545]
* Add menu item to select sheet objects. [#338615]
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index e4dc3e4..bd68070 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,14 @@
+2009-12-28 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * dialog-sheetobject-size.c (dialog_so_size_button_sensitivity):
+ handle position
+ (cb_dialog_so_size_destroy): ditto
+ (cb_dialog_so_size_value_changed): ditto
+ (dialog_so_size_load): ditto
+ (cb_dialog_so_size_apply_clicked): ditto
+ (dialog_so_size): ditto
+ * sheetobject-size.glade: add position section
+
2009-12-27 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-sheetobject-size.c (dialog_so_size_button_sensitivity):
diff --git a/src/dialogs/dialog-sheetobject-size.c b/src/dialogs/dialog-sheetobject-size.c
index d0058e1..f26bc97 100644
--- a/src/dialogs/dialog-sheetobject-size.c
+++ b/src/dialogs/dialog-sheetobject-size.c
@@ -59,6 +59,10 @@ typedef struct {
GtkSpinButton *wspin;
GtkWidget *hpoints;
GtkSpinButton *hspin;
+ GtkWidget *xpoints;
+ GtkSpinButton *xspin;
+ GtkWidget *ypoints;
+ GtkSpinButton *yspin;
GtkEntry *nameentry;
SheetObject *so;
@@ -66,7 +70,8 @@ typedef struct {
SheetObjectAnchor *active_anchor;
double coords[4];
gchar *old_name;
- gboolean so_needs_restore;
+ gboolean so_size_needs_restore;
+ gboolean so_pos_needs_restore;
gboolean so_name_changed;
} SOSizeState;
@@ -84,18 +89,19 @@ cb_dialog_so_size_value_changed_update_points (GtkSpinButton *spinbutton,
static void
dialog_so_size_button_sensitivity (SOSizeState *state)
{
+ gboolean sensitive = state->so_size_needs_restore ||
+ state->so_pos_needs_restore ||
+ state->so_name_changed;
gtk_widget_set_sensitive
- (state->ok_button,
- state->so_needs_restore || state->so_name_changed);
+ (state->ok_button, sensitive);
gtk_widget_set_sensitive
- (state->apply_button,
- state->so_needs_restore || state->so_name_changed);
+ (state->apply_button, sensitive);
}
static void
cb_dialog_so_size_destroy (SOSizeState *state)
{
- if (state->so_needs_restore)
+ if (state->so_size_needs_restore || state->so_pos_needs_restore)
sheet_object_set_anchor (state->so, state->old_anchor);
g_free (state->old_anchor);
g_free (state->active_anchor);
@@ -121,6 +127,7 @@ cb_dialog_so_size_value_changed (G_GNUC_UNUSED GtkSpinButton *spinbutton,
{
int width, height;
int new_width, new_height;
+ int dx, dy;
width = state->coords[2] - state->coords[0];
height = state->coords[3] - state->coords[1];
@@ -129,18 +136,21 @@ cb_dialog_so_size_value_changed (G_GNUC_UNUSED GtkSpinButton *spinbutton,
new_width = gtk_spin_button_get_value_as_int (state->wspin);
new_height = gtk_spin_button_get_value_as_int (state->hspin);
+ dx = gtk_spin_button_get_value_as_int (state->xspin);
+ dy = gtk_spin_button_get_value_as_int (state->yspin);
- state->so_needs_restore = (new_width != width) || (new_height != height);
+ state->so_size_needs_restore = (new_width != width) || (new_height != height);
+ state->so_pos_needs_restore = (dx != 0) || (dy != 0);
*(state->active_anchor) = *(state->old_anchor);
- if (state->so_needs_restore) {
+ if (state->so_size_needs_restore || state->so_pos_needs_restore) {
gdouble new_coords[4];
- new_coords[0] = state->coords[0];
- new_coords[1] = state->coords[1];
- new_coords[2] = state->coords[2];
- new_coords[3] = state->coords[3];
+ new_coords[0] = state->coords[0] + dx;
+ new_coords[1] = state->coords[1] + dy;
+ new_coords[2] = state->coords[2] + dx;
+ new_coords[3] = state->coords[3] + dy;
if (new_coords[0] < new_coords[2])
new_coords[2] = new_coords[0] + new_width;
else
@@ -168,7 +178,8 @@ dialog_so_size_load (SOSizeState *state)
scg_object_anchor_to_coords (state->scg,
state->old_anchor,
state->coords);
- state->so_needs_restore = FALSE;
+ state->so_size_needs_restore = FALSE;
+ state->so_pos_needs_restore = FALSE;
}
@@ -178,14 +189,16 @@ cb_dialog_so_size_apply_clicked (G_GNUC_UNUSED GtkWidget *button,
{
char const *name;
- if (state->so_needs_restore) {
+ if (state->so_size_needs_restore || state->so_pos_needs_restore) {
+ char const *label = state->so_pos_needs_restore ?
+ _("Move Object") : _("Resize Object");
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")))
+ FALSE, label))
dialog_so_size_load (state);
}
@@ -207,7 +220,8 @@ static void
cb_dialog_so_size_ok_clicked (GtkWidget *button, SOSizeState *state)
{
cb_dialog_so_size_apply_clicked (button, state);
- if (!state->so_needs_restore)
+ if (!state->so_size_needs_restore && !state->so_pos_needs_restore &&
+ !state->so_name_changed)
gtk_widget_destroy (state->dialog);
return;
}
@@ -267,19 +281,24 @@ dialog_so_size (WBCGtk *wbcg, GObject *so)
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"));
state->hpoints = GTK_WIDGET (glade_xml_get_widget (state->gui, "h-pts-label"));
state->hspin = GTK_SPIN_BUTTON (glade_xml_get_widget (state->gui, "h-spin"));
+ state->xpoints = GTK_WIDGET (glade_xml_get_widget (state->gui, "x-pts-label"));
+ state->xspin = GTK_SPIN_BUTTON (glade_xml_get_widget (state->gui, "x-spin"));
+ state->ypoints = GTK_WIDGET (glade_xml_get_widget (state->gui, "y-pts-label"));
+ state->yspin = GTK_SPIN_BUTTON (glade_xml_get_widget (state->gui, "y-spin"));
dialog_so_size_load (state);
state->active_anchor = sheet_object_anchor_dup (sheet_object_get_anchor (state->so));
width = state->coords[2] - state->coords[0];
height = state->coords[3] - state->coords[1];
+ gtk_spin_button_set_value (state->wspin, (width < 0) ? - width : width);
+ gtk_spin_button_set_value (state->hspin, (height < 0) ? - height : height);
+ gtk_spin_button_set_value (state->xspin, 0.);
+ gtk_spin_button_set_value (state->yspin, 0.);
g_signal_connect (G_OBJECT (state->wspin),
"value-changed",
G_CALLBACK (cb_dialog_so_size_value_changed_update_points),
@@ -288,8 +307,19 @@ dialog_so_size (WBCGtk *wbcg, GObject *so)
"value-changed",
G_CALLBACK (cb_dialog_so_size_value_changed_update_points),
state->hpoints);
- gtk_spin_button_set_value (state->wspin, (width < 0) ? - width : width);
- gtk_spin_button_set_value (state->hspin, (height < 0) ? - height : height);
+ g_signal_connect (G_OBJECT (state->xspin),
+ "value-changed",
+ G_CALLBACK (cb_dialog_so_size_value_changed_update_points),
+ state->xpoints);
+ g_signal_connect (G_OBJECT (state->yspin),
+ "value-changed",
+ G_CALLBACK (cb_dialog_so_size_value_changed_update_points),
+ state->ypoints);
+ cb_dialog_so_size_value_changed_update_points (state->wspin, GTK_LABEL (state->wpoints));
+ cb_dialog_so_size_value_changed_update_points (state->hspin, GTK_LABEL (state->hpoints));
+ cb_dialog_so_size_value_changed_update_points (state->xspin, GTK_LABEL (state->xpoints));
+ cb_dialog_so_size_value_changed_update_points (state->yspin, GTK_LABEL (state->ypoints));
+
g_signal_connect (G_OBJECT (state->wspin),
"value-changed",
@@ -297,6 +327,12 @@ dialog_so_size (WBCGtk *wbcg, GObject *so)
g_signal_connect (G_OBJECT (state->hspin),
"value-changed",
G_CALLBACK (cb_dialog_so_size_value_changed), state);
+ g_signal_connect (G_OBJECT (state->xspin),
+ "value-changed",
+ G_CALLBACK (cb_dialog_so_size_value_changed), state);
+ g_signal_connect (G_OBJECT (state->yspin),
+ "value-changed",
+ G_CALLBACK (cb_dialog_so_size_value_changed), state);
state->ok_button = glade_xml_get_widget (state->gui, "ok_button");
g_signal_connect (G_OBJECT (state->ok_button),
diff --git a/src/dialogs/sheetobject-size.glade b/src/dialogs/sheetobject-size.glade
index 7fae02c..4fb925c 100644
--- a/src/dialogs/sheetobject-size.glade
+++ b/src/dialogs/sheetobject-size.glade
@@ -1,5 +1,7 @@
<?xml version="1.0"?>
<glade-interface>
+ <!-- interface-requires gtk+ 2.6 -->
+ <!-- interface-naming-policy toplevel-contextual -->
<widget class="GtkDialog" id="object-size">
<property name="border_width">6</property>
<property name="title" translatable="yes">Size & Position</property>
@@ -8,15 +10,16 @@
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
+ <property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<widget class="GtkTable" id="main_table">
<property name="visible">True</property>
<property name="border_width">8</property>
- <property name="n_rows">4</property>
+ <property name="n_rows">9</property>
<property name="n_columns">4</property>
<property name="column_spacing">12</property>
- <property name="row_spacing">12</property>
+ <property name="row_spacing">5</property>
<child>
<widget class="GtkSpinButton" id="w-spin">
<property name="visible">True</property>
@@ -47,7 +50,7 @@
</child>
<child>
<widget class="GtkLabel" id="w-pts-label">
- <property name="width_request">72</property>
+ <property name="width_request">60</property>
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="xpad">3</property>
@@ -123,7 +126,7 @@
</child>
<child>
<widget class="GtkLabel" id="h-pts-label">
- <property name="width_request">72</property>
+ <property name="width_request">60</property>
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="xpad">3</property>
@@ -144,8 +147,8 @@
</widget>
<packing>
<property name="right_attach">4</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">6</property>
+ <property name="bottom_attach">7</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@@ -153,14 +156,14 @@
<child>
<widget class="GtkLabel" id="name">
<property name="visible">True</property>
- <property name="sensitive">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Name:</property>
<property name="use_underline">True</property>
+ <property name="mnemonic_widget">name-entry</property>
</widget>
<packing>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="top_attach">7</property>
+ <property name="bottom_attach">8</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@@ -168,7 +171,6 @@
<child>
<widget class="GtkEntry" id="name-entry">
<property name="visible">True</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>
@@ -176,8 +178,176 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">4</property>
+ <property name="top_attach">7</property>
+ <property name="bottom_attach">8</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Object position relative to its current position:</property>
+ </widget>
+ <packing>
+ <property name="right_attach">4</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_x-Offset in pixels:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">x-spin</property>
+ </widget>
+ <packing>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_y-Offset in pixels:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">y-spin</property>
+ </widget>
+ <packing>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkSpinButton" id="x-spin">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <property name="xalign">1</property>
+ <property name="adjustment">0 -10000 10000 1 5 0</property>
+ <property name="climb_rate">1</property>
+ <property name="numeric">True</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkSpinButton" id="y-spin">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <property name="xalign">1</property>
+ <property name="adjustment">0 -10000 10000 1 5 0</property>
+ <property name="climb_rate">1</property>
+ <property name="numeric">True</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="x-pts-label">
+ <property name="width_request">60</property>
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="xpad">3</property>
+ <property name="label" translatable="yes">x</property>
+ </widget>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="y-pts-label">
+ <property name="width_request">60</property>
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="xpad">3</property>
+ <property name="label" translatable="yes">x</property>
+ </widget>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">x-Offset in points:</property>
+ <property name="use_underline">True</property>
+ </widget>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">y-Offset in points:</property>
+ <property name="use_underline">True</property>
+ </widget>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHSeparator" id="hseparator2">
+ <property name="visible">True</property>
+ </widget>
+ <packing>
+ <property name="right_attach">4</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHSeparator" id="hseparator3">
+ <property name="visible">True</property>
+ </widget>
+ <packing>
+ <property name="right_attach">4</property>
+ <property name="top_attach">8</property>
+ <property name="bottom_attach">9</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
diff --git a/src/sheet-object.c b/src/sheet-object.c
index 4b9304c..cfe716a 100644
--- a/src/sheet-object.c
+++ b/src/sheet-object.c
@@ -158,7 +158,7 @@ sheet_object_populate_menu_real (SheetObject *so, GPtrArray *actions)
static SheetObjectAction const so_actions [] = {
{ "gtk-properties", NULL, NULL, 0, sheet_object_get_editor },
{ NULL, NULL, NULL, 0, NULL },
- { GTK_STOCK_LEAVE_FULLSCREEN, N_("Si_ze"), NULL, 0, cb_so_size_position },
+ { GTK_STOCK_LEAVE_FULLSCREEN, N_("Size _& Position"), NULL, 0, cb_so_size_position },
{ "gtk-fullscreen", N_("_Snap to Grid"), NULL, 0, cb_so_snap_to_grid },
{ NULL, N_("_Order"), NULL, 1, NULL },
{ NULL, N_("Pul_l to Front"), NULL, 0, cb_so_pull_to_front },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]