Commit e3d0bee1 authored by Andreas J. Guelzow 's avatar Andreas J. Guelzow

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"
parent 87f8de06
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
......
......@@ -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]
......
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):
......
......@@ -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),
......
<?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 &amp; 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,16 +171,183 @@
<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">&#x2022;</property>
</widget>
<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">&#x2022;</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">&#x2022;</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>
......
......@@ -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 },
......
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