Commit 7a582e7b authored by Jean Bréfort's avatar Jean Bréfort

fixes to the component and to so-filled items

parent 92610df4
2009-09-23 Jean Brefort <jean.brefort@normalesup.org>
* component/gnumeric.c (cb_gognm_save), (go_gnm_component_edit): allow
edition of not embedded workbooks as well.
* src/GNOME_Gnumeric-gtk.xml.in: fixed Save button action.
* src/gnm-so-filled.c (cb_gnm_so_filled_changed),
(gnm_so_filled_draw_cairo): printf with the same font as screen display.
* src/wbc-gtk-impl.h: fixed menus for the component.
* src/wbc-gtk.c (set_uifilename), (wbc_gtk_init): ditto.
2009-09-22 Andreas J. Guelzow <aguelzow@pyrshep.ca>
modified patches from Albert Gräf <Dr.Graef@t-online.de>
......
......@@ -3,7 +3,7 @@
* Gnumeric GOffice component
* gnumeric.c
*
* Copyright (C) 2006-2008
* Copyright (C) 2006-2009
*
* Developed by Jean Bréfort <jean.brefort@normalesup.org>
*
......@@ -27,6 +27,7 @@
#include <gnumeric.h>
#include <gnm-plugin.h>
#include <gnumeric-gconf.h>
#include <gui-file.h>
#include <gutils.h>
#include <print-cell.h>
#include <print.h>
......@@ -157,8 +158,12 @@ go_gnm_component_render (GOComponent *component, cairo_t *cr, double width_pixel
static void
cb_gognm_save (GtkAction *a, WBCGtk *wbcg)
{
GOComponent *component = GO_COMPONENT (g_object_get_data (G_OBJECT (wbcg), "component"));
go_component_emit_changed (component);
gpointer data = g_object_get_data (G_OBJECT (wbcg), "component");
if (GO_IS_COMPONENT (data)) {
GOComponent *component = GO_COMPONENT (data);
go_component_emit_changed (component);
} else
gui_file_save (wbcg, wb_control_view (WORKBOOK_CONTROL (wbcg)));
}
static GtkActionEntry const actions[] = {
......@@ -197,10 +202,8 @@ go_gnm_component_edit (GOComponent *component)
wv = wb_view_new_from_input (input, NULL, io_context, NULL);
g_object_unref (io_context);
}
set_uifilename ("Gnumeric-embed.xml");
set_uifilename ("Gnumeric-embed.xml", actions, G_N_ELEMENTS (actions));
gognm->edited = wbc_gtk_new (wv, NULL, NULL, NULL);
gtk_action_group_add_actions (gognm->edited->actions,
actions, G_N_ELEMENTS (actions), gognm->edited);
g_object_set_data (G_OBJECT (gognm->edited), "component", gognm);
g_signal_connect_swapped (gognm->edited->toplevel, "destroy",
......
......@@ -22,6 +22,7 @@
#include <gnumeric-config.h>
#include "gnumeric.h"
#include "application.h"
#include "gnm-so-filled.h"
#include "sheet-object-impl.h"
#include "xml-sax.h"
......@@ -185,14 +186,31 @@ cb_gnm_so_filled_changed (GnmSOFilled const *sof,
cb_gnm_so_filled_style_changed (GOC_ITEM (group->bg), sof);
if (sof->text != NULL) {
if (group->text == NULL)
group->text = goc_item_new (GOC_GROUP (group), GOC_TYPE_TEXT,
"anchor", sof->is_oval? GTK_ANCHOR_CENTER: GTK_ANCHOR_NW,
"clip", TRUE,
"x", sof->margin_pts.left,
"y", sof->margin_pts.top,
"attributes", sof->markup,
NULL);
/* set a font, a very bad solution, but will do until we move to GOString */
PangoFontDescription *desc = pango_font_description_from_string ("Sans 10");
GOStyle *style;
if (group->text == NULL) {
if (sof->is_oval) {
double w, h;
g_object_get (group->bg, "width", &w, "height", &h, NULL);
group->text = goc_item_new (GOC_GROUP (group), GOC_TYPE_TEXT,
"anchor", GTK_ANCHOR_CENTER,
"clip", TRUE,
"x", w / 2.,
"y", h / 2.,
"attributes", sof->markup,
NULL);
} else
group->text = goc_item_new (GOC_GROUP (group), GOC_TYPE_TEXT,
"anchor", GTK_ANCHOR_NW,
"clip", TRUE,
"x", sof->margin_pts.left,
"y", sof->margin_pts.top,
"attributes", sof->markup,
NULL);
}
style = go_styled_object_get_style (GO_STYLED_OBJECT (group->text));
go_style_set_font_desc (style, desc);
goc_item_set (group->text,
"text", sof->text,
"attributes", sof->markup,
......@@ -269,13 +287,29 @@ gnm_so_filled_draw_cairo (SheetObject const *so, cairo_t *cr,
- sof->margin_pts.bottom) * PANGO_SCALE;
double pl_width = (width - sof->margin_pts.left
- sof->margin_pts.right) * PANGO_SCALE;
cairo_move_to (cr, sof->margin_pts.left,
sof->margin_pts.top);
/* set a font, a very bad solution, but will do until we move to GOString */
PangoFontDescription *desc = pango_font_description_from_string ("Sans 10");
double const scale_h = 72. / gnm_app_display_dpi_get (TRUE);
double const scale_v = 72. / gnm_app_display_dpi_get (FALSE);
pango_layout_set_font_description (pl, desc);
pango_layout_set_text (pl, sof->text, -1);
pango_layout_set_attributes (pl, sof->markup);
pango_layout_set_width (pl, pl_width);
pango_layout_set_height (pl, pl_height);
cairo_save (cr);
if (sof->is_oval) {
PangoRectangle r;
pango_layout_get_extents (pl, NULL, &r);
cairo_move_to (cr,
(width - r.width / PANGO_SCALE * scale_h) / 2.,
(height - r.height / PANGO_SCALE * scale_v) / 2.);
} else
cairo_move_to (cr, sof->margin_pts.left,
sof->margin_pts.top);
cairo_scale (cr, scale_h, scale_v);
pango_cairo_show_layout (cr, pl);
cairo_new_path (cr);
cairo_restore (cr);
g_object_unref(G_OBJECT (pl));
}
}
......
......@@ -170,7 +170,7 @@ void wbc_gtk_markup_changer (WBCGtk *wbcg);
gboolean wbc_gtk_load_templates (WBCGtk *gtk);
#ifndef HILDON
G_MODULE_EXPORT void set_uifilename (char const *name);
G_MODULE_EXPORT void set_uifilename (char const *name, GtkActionEntry const *actions, int nb);
#endif
G_END_DECLS
......
......@@ -92,6 +92,8 @@ enum {
#ifndef HILDON
char const *uifilename = NULL;
GtkActionEntry const *extra_actions = NULL;
int extra_actions_nb;
#endif
static guint wbc_gtk_signals[WBC_GTK_LAST_SIGNAL];
static GObjectClass *parent_class = NULL;
......@@ -100,9 +102,11 @@ static GObjectClass *parent_class = NULL;
#ifndef HILDON
G_MODULE_EXPORT void
set_uifilename (char const *name)
set_uifilename (char const *name, GtkActionEntry const *actions, int nb)
{
uifilename = name;
extra_actions = actions;
extra_actions_nb = nb;
}
#endif
......@@ -5056,6 +5060,10 @@ wbc_gtk_init (GObject *obj)
#ifdef GNM_USE_HILDON
uifile = g_build_filename (gnm_sys_data_dir (), "HILDON_Gnumeric-gtk.xml", NULL);
#else
if (extra_actions)
gtk_action_group_add_actions (wbcg->actions, extra_actions,
extra_actions_nb, wbcg);
uifile = g_build_filename (gnm_sys_data_dir (),
(uifilename? uifilename: "GNOME_Gnumeric-gtk.xml"), NULL);
#endif
......
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