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

Allow sheet object sizes to be specified via a dialog

2009-12-26  Andreas J. Guelzow <aguelzow@pyrshep.ca>

	* POTFILES.in: added src/dialogs/dialog-sheetobject-size.c
	* POTFILES.skip: added src/dialogs/sheetobject-size.glade

2009-12-26  Andreas J. Guelzow <aguelzow@pyrshep.ca>

	* POTFILES.in: added src/dialogs/dialog-sheetobject-size.c and
	  src/dialogs/sheetobject-size.glade

2009-12-26 Andreas J. Guelzow <aguelzow@pyrshep.ca>

	* Makefile.am: add dialog-sheetobject-size.c and
	  sheetobject-size.glade
	* help.h (GNUMERIC_HELP_LINK_SO_SIZE): new
	* dialogs.h (dialog_so_size): new

2009-12-26  Andreas J. Guelzow <aguelzow@pyrshep.ca>

	* src/sheet-object.c (cb_so_size_position): new
	(so_actions): add menu item
parent 5db21d1e
2009-12-26 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* src/sheet-object.c (cb_so_size_position): new
(so_actions): add menu item
2009-12-24 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* src/sheet-object-widget.c (sheet_widget_ ## n1 ## _class_init):
......
2009-12-26 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* POTFILES.in: added src/dialogs/dialog-sheetobject-size.c
* POTFILES.skip: added src/dialogs/sheetobject-size.glade
2009-12-22 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* POTFILES.in: added src/dialogs/dialog-analysis-tool-principal-components.c
......
......@@ -116,6 +116,7 @@ src/dialogs/dialog-scenarios.c
src/dialogs/dialog-search-replace.c
src/dialogs/dialog-search.c
src/dialogs/dialog-sheet-order.c
src/dialogs/dialog-sheetobject-size.c
src/dialogs/dialog-shuffle.c
src/dialogs/dialog-simulation.c
src/dialogs/dialog-so-list.c
......
......@@ -128,6 +128,7 @@ src/dialogs/scenario-manager.glade
src/dialogs/search-replace.glade
src/dialogs/sheet-order.glade
src/dialogs/sheet-resize.glade
src/dialogs/sheetobject-size.glade
src/dialogs/shuffle.glade
src/dialogs/simulation.glade
src/dialogs/sign-test.glade
......
2009-12-26 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* POTFILES.in: added src/dialogs/dialog-sheetobject-size.c and
src/dialogs/sheetobject-size.glade
2009-12-22 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* POTFILES.in: added src/dialogs/dialog-analysis--principal-components.c,
* POTFILES.in: added
src/dialogs/dialog-analysis-principal-components.c,
src/tools/analysis-principal-components.c and
src/dialogs/principal-components.glade
......
......@@ -196,6 +196,7 @@ src/dialogs/dialog-scenarios.c
src/dialogs/dialog-search-replace.c
src/dialogs/dialog-search.c
src/dialogs/dialog-sheet-order.c
src/dialogs/dialog-sheetobject-size.c
src/dialogs/dialog-shuffle.c
src/dialogs/dialog-simulation.c
src/dialogs/dialog-so-list.c
......@@ -254,6 +255,7 @@ src/dialogs/search-replace.glade
[type: gettext/glade]src/dialogs/search.ui
src/dialogs/sheet-order.glade
src/dialogs/sheet-resize.glade
src/dialogs/sheetobject-size.glade
src/dialogs/shuffle.glade
src/dialogs/simulation.glade
src/dialogs/sign-test.glade
......
2009-12-26 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* Makefile.am: add dialog-sheetobject-size.c and
sheetobject-size.glade
* help.h (GNUMERIC_HELP_LINK_SO_SIZE): new
* dialogs.h (dialog_so_size): new
2009-12-24 Jean Brefort <jean.brefort@normalesup.org>
* dialog-preferences.c: Fixed double/gnm_float issues.
......
......@@ -68,6 +68,7 @@ base_files = \
dialog-search-replace.c \
dialog-sheet-order.c \
dialog-sheet-resize.c \
dialog-sheetobject-size.c \
dialog-shuffle.c \
dialog-simulation.c \
dialog-so-list.c \
......@@ -154,6 +155,7 @@ glade_DATA = \
search-replace.glade \
sheet-order.glade \
sheet-resize.glade \
sheetobject-size.glade \
shuffle.glade \
sign-test.glade \
sign-test-two.glade \
......
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/**
* dialog-sheetobject-size.c:
*
* Author:
* Andreas J. Guelzow <aguelzow@pyrshep.ca>
*
* (c) Copyright 2009 Andreas J. Guelzow <aguelzow@pyrshep.ca>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <gnumeric-config.h>
#include <glib/gi18n-lib.h>
#include <gnumeric.h>
#include "dialogs.h"
#include "help.h"
#include <gui-util.h>
#include <commands.h>
#include <workbook-control.h>
#include <workbook.h>
#include <wbc-gtk.h>
#include <sheet.h>
#include <sheet-view.h>
#include <sheet-control-gui-priv.h>
#include <application.h>
#include <workbook-cmd-format.h>
#include <sheet-object-widget.h>
#include <sheet-control-gui.h>
#include <glade/glade.h>
#include <gtk/gtk.h>
#define SO_SIZE_DIALOG_KEY "so-size-dialog"
typedef struct {
GladeXML *gui;
WBCGtk *wbcg;
Sheet *sheet;
SheetView *sv;
SheetControlGUI *scg;
GtkWidget *dialog;
GtkWidget *ok_button;
GtkWidget *apply_button;
GtkWidget *cancel_button;
GtkWidget *wpoints;
GtkSpinButton *wspin;
GtkWidget *hpoints;
GtkSpinButton *hspin;
SheetObject *so;
SheetObjectAnchor *old_anchor;
SheetObjectAnchor *active_anchor;
double coords[4];
gboolean so_needs_restore;
} SOSizeState;
static void
cb_dialog_so_size_value_changed_update_points (GtkSpinButton *spinbutton,
GtkLabel *points)
{
gint value = gtk_spin_button_get_value_as_int (spinbutton);
double size_points = value * 72./gnm_app_display_dpi_get (FALSE);
gchar *pts = g_strdup_printf ("%.2f",size_points);
gtk_label_set_text (points, pts);
g_free (pts);
}
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);
}
static void
cb_dialog_so_size_destroy (SOSizeState *state)
{
if (state->so_needs_restore)
sheet_object_set_anchor (state->so, state->old_anchor);
g_free (state->old_anchor);
g_free (state->active_anchor);
if (state->so!= NULL)
g_object_unref (G_OBJECT (state->so));
if (state->gui != NULL)
g_object_unref (G_OBJECT (state->gui));
g_free (state);
}
static void
cb_dialog_so_size_cancel_clicked (G_GNUC_UNUSED GtkWidget *button,
SOSizeState *state)
{
gtk_widget_destroy (state->dialog);
return;
}
static void
cb_dialog_so_size_value_changed (G_GNUC_UNUSED GtkSpinButton *spinbutton,
SOSizeState *state)
{
int width, height;
int new_width, new_height;
width = state->coords[2] - state->coords[0];
height = state->coords[3] - state->coords[1];
if (width < 0) width = - width;
if (height < 0) height = - height;
new_width = gtk_spin_button_get_value_as_int (state->wspin);
new_height = gtk_spin_button_get_value_as_int (state->hspin);
state->so_needs_restore = (new_width != width) || (new_height != height);
*(state->active_anchor) = *(state->old_anchor);
if (state->so_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];
if (new_coords[0] < new_coords[2])
new_coords[2] = new_coords[0] + new_width;
else
new_coords[0] = new_coords[2] + new_width;
if (new_coords[1] < new_coords[3])
new_coords[3] = new_coords[1] + new_height;
else
new_coords[1] = new_coords[3] + new_height;
scg_object_coords_to_anchor (state->scg, new_coords, state->active_anchor);
}
sheet_object_set_anchor (state->so, state->active_anchor);
dialog_so_size_button_sensitivity (state);
}
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->so_needs_restore = FALSE;
}
static void
cb_dialog_so_size_apply_clicked (G_GNUC_UNUSED GtkWidget *button,
SOSizeState *state)
{
if (!state->so_needs_restore)
return;
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);
dialog_so_size_button_sensitivity (state);
return;
}
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)
gtk_widget_destroy (state->dialog);
return;
}
void
dialog_so_size (WBCGtk *wbcg, GObject *so)
{
GladeXML *gui;
SOSizeState *state;
int width, height;
g_return_if_fail (wbcg != NULL);
if (gnumeric_dialog_raise_if_exists (wbcg, SO_SIZE_DIALOG_KEY))
return;
gui = gnm_glade_xml_new (GO_CMD_CONTEXT (wbcg),
"sheetobject-size.glade", NULL, NULL);
if (gui == NULL)
return;
state = g_new (SOSizeState, 1);
state->wbcg = wbcg;
state->sv = wb_control_cur_sheet_view (WORKBOOK_CONTROL (wbcg));
state->sheet = sv_sheet (state->sv);
state->scg = wbcg_get_nth_scg (wbcg, state->sheet->index_in_wb);
state->gui = gui;
state->dialog = glade_xml_get_widget (state->gui, "object-size");
state->so = SHEET_OBJECT (so);
g_object_ref (so);
state->old_anchor = NULL;
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"));
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];
g_signal_connect (G_OBJECT (state->wspin),
"value-changed",
G_CALLBACK (cb_dialog_so_size_value_changed_update_points),
state->wpoints);
g_signal_connect (G_OBJECT (state->hspin),
"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->wspin),
"value-changed",
G_CALLBACK (cb_dialog_so_size_value_changed), state);
g_signal_connect (G_OBJECT (state->hspin),
"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),
"clicked",
G_CALLBACK (cb_dialog_so_size_ok_clicked), state);
state->apply_button = glade_xml_get_widget (state->gui, "apply_button");
g_signal_connect (G_OBJECT (state->apply_button),
"clicked",
G_CALLBACK (cb_dialog_so_size_apply_clicked), state);
state->cancel_button = glade_xml_get_widget (state->gui, "cancel_button");
g_signal_connect (G_OBJECT (state->cancel_button),
"clicked",
G_CALLBACK (cb_dialog_so_size_cancel_clicked), state);
gnumeric_init_help_button (
glade_xml_get_widget (state->gui, "help_button"),
GNUMERIC_HELP_LINK_SO_SIZE);
gnm_dialog_setup_destroy_handlers (GTK_DIALOG (state->dialog),
state->wbcg,
GNM_DIALOG_DESTROY_CURRENT_SHEET_REMOVED);
wbc_gtk_attach_guru (state->wbcg, state->dialog);
g_object_set_data_full (G_OBJECT (state->dialog),
"state", state, (GDestroyNotify) cb_dialog_so_size_destroy);
gnumeric_keyed_dialog (wbcg, GTK_WINDOW (state->dialog),
SO_SIZE_DIALOG_KEY);
dialog_so_size_button_sensitivity (state);
gtk_widget_show (state->dialog);
}
......@@ -132,4 +132,7 @@ void dialog_doc_metadata_new (WBCGtk *wbcg, int page);
void dialog_quit (WBCGtk *wbcg);
void dialog_so_size (WBCGtk *wbcg, GObject *so);
#endif /* GNUMERIC_DIALOGS_H */
......@@ -25,6 +25,9 @@
#define GNUMERIC_HELP_LINK_SO_CHECKBOX "sect-graphics-drawings"
#define GNUMERIC_HELP_LINK_SO_LIST "sect-graphics-drawings"
/* dialog-sheetobject-size.c */
#define GNUMERIC_HELP_LINK_SO_SIZE "sect-graphics-drawings"
/* dialog-autofilter.c */
#define GNUMERIC_HELP_LINK_AUTOFILTER_TOP_TEN "sect-data-modify"
#define GNUMERIC_HELP_LINK_AUTOFILTER_CUSTOM "sect-data-modify"
......
<?xml version="1.0"?>
<glade-interface>
<widget class="GtkDialog" id="object-size">
<property name="border_width">6</property>
<property name="title" translatable="yes">Size &amp; Position</property>
<property name="type_hint">dialog</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</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_columns">4</property>
<property name="column_spacing">12</property>
<property name="row_spacing">12</property>
<child>
<widget class="GtkSpinButton" id="w-spin">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="xalign">1</property>
<property name="adjustment">5 4 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="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Width in pixels:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">w-spin</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="w-pts-label">
<property name="width_request">72</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="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Width in points:</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Height in pixels:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">h-spin</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="h-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">5 4 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">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Height in points:</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="h-pts-label">
<property name="width_request">72</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">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator1">
<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="GtkLabel" id="name">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Name:</property>
<property name="use_underline">True</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="name-entry">
<property name="visible">True</property>
<property name="sensitive">False</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">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<widget class="GtkButton" id="help_button">
<property name="label">gtk-help</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="apply_button">
<property name="label">gtk-apply</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="cancel_button">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="ok_button">
<property name="label">gtk-ok</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>
......@@ -63,6 +63,13 @@ static GObjectClass *parent_klass;
static GQuark sov_so_quark;
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);
}
static void
cb_so_snap_to_grid (SheetObject *so, SheetControl *sc)
{
......@@ -129,6 +136,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-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