row, column);
}
-/**
- * g_sheet_model_get_font_desc:
- * @sheet_model: A #GSheetModel
- * @row: The row
- * @column: The column
- *
- * Returns the font description of the cell at @row, @column
- * Returns: the font description, or NULL on error.
- **/
-const PangoFontDescription *
-g_sheet_model_get_font_desc(const GSheetModel *model,
- glong row, glong column)
-{
- g_return_val_if_fail (G_IS_SHEET_MODEL (model), NULL);
- if ( ! G_SHEET_MODEL_GET_IFACE (model)->get_font_desc)
- return NULL;
-
- return G_SHEET_MODEL_GET_IFACE (model)->get_font_desc (model,
- row, column);
-}
-
/**
* g_sheet_model_get_cell_border:
* @sheet_model: A #GSheetModel
const GtkJustification * (* get_justification) (const GSheetModel *sheet_model,
glong row, glong column);
- const PangoFontDescription * (* get_font_desc) (const GSheetModel *sheet_model,
- glong row, glong column);
-
const GtkSheetCellBorder * (* get_cell_border) (const GSheetModel *sheet_model,
glong row, glong column);
GdkColor *g_sheet_model_get_background
(const GSheetModel *model, glong row, glong column);
-
const GtkJustification *g_sheet_model_get_justification
(const GSheetModel *model, glong row, glong column);
-
-const PangoFontDescription *g_sheet_model_get_font_desc
- (const GSheetModel *model, glong row, glong column);
-
const GtkSheetCellBorder * g_sheet_model_get_cell_border
(const GSheetModel *model, glong row, glong column);
#define DEFAULT_COLUMN_WIDTH 80
#define DEFAULT_ROW_HEIGHT 25
+static void set_entry_widget_font (GtkSheet *sheet);
+
static void gtk_sheet_update_primary_selection (GtkSheet *sheet);
static void draw_column_title_buttons_range (GtkSheet *sheet, gint first, gint n);
static void draw_row_title_buttons_range (GtkSheet *sheet, gint first, gint n);
static void gtk_sheet_unmap (GtkWidget *widget);
static gint gtk_sheet_expose (GtkWidget *widget,
GdkEventExpose *event);
+
static void gtk_sheet_forall (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
gtk_style_set_background (widget->style, widget->window, widget->state);
}
+ set_entry_widget_font (sheet);
}
#define BORDER_WIDTH 2
{
PangoLayout *layout;
PangoRectangle text;
+ PangoFontDescription *font_desc = GTK_WIDGET (sheet)->style->font_desc;
gint font_height;
gchar *label;
layout = gtk_widget_create_pango_layout (GTK_WIDGET (sheet), label);
dispose_string (sheet, label);
- pango_layout_set_font_description (layout, attributes.font_desc);
+ pango_layout_set_font_description (layout, font_desc);
+
pango_layout_get_pixel_extents (layout, NULL, &text);
gdk_gc_set_clip_rectangle (sheet->fg_gc, &area);
- font_height = pango_font_description_get_size (attributes.font_desc);
- if ( !pango_font_description_get_size_is_absolute (attributes.font_desc))
+ font_height = pango_font_description_get_size (font_desc);
+ if ( !pango_font_description_get_size_is_absolute (font_desc))
font_height /= PANGO_SCALE;
/* Centre the text vertically */
}
+/* Copy the sheet's font to the entry widget */
+static void
+set_entry_widget_font (GtkSheet *sheet)
+{
+ GtkRcStyle *style = gtk_widget_get_modifier_style (sheet->entry_widget);
+
+ pango_font_description_free (style->font_desc);
+ style->font_desc = pango_font_description_copy (GTK_WIDGET (sheet)->style->font_desc);
+
+ gtk_widget_modify_style (sheet->entry_widget, style);
+}
+
+
+
static void
create_sheet_entry (GtkSheet *sheet)
{
G_CALLBACK (gtk_sheet_entry_changed),
sheet);
+ set_entry_widget_font (sheet);
+
gtk_widget_show (sheet->entry_widget);
}
{
GdkColor *fg, *bg;
const GtkJustification *j ;
- const PangoFontDescription *font_desc ;
const GtkSheetCellBorder *border ;
GdkColormap *colormap;
attr->border.join_style = GDK_JOIN_MITER;
attr->border.mask = 0;
attr->border.color = GTK_WIDGET (sheet)->style->black;
- attr->font_desc = GTK_WIDGET (sheet)->style->font_desc;
attr->is_editable = g_sheet_model_is_editable (sheet->model, row, col);
if (j)
attr->justification = *j;
- font_desc = g_sheet_model_get_font_desc (sheet->model, row, col);
- if ( font_desc ) attr->font_desc = font_desc;
-
border = g_sheet_model_get_cell_border (sheet->model, row, col);
if ( border ) attr->border = *border;
struct _GtkSheetCellAttr
{
GtkJustification justification;
- const PangoFontDescription *font_desc;
GdkColor foreground;
GdkColor background;
GtkSheetCellBorder border;
fonts_activate (GtkMenuItem *menuitem, gpointer data)
{
struct data_editor *de = data;
+ PangoFontDescription *current_font;
+ gchar *font_name;
GtkWidget *dialog =
gtk_font_selection_dialog_new (_("Font Selection"));
+
+ current_font = GTK_WIDGET(de->data_editor)->style->font_desc;
+ font_name = pango_font_description_to_string (current_font);
+
+ gtk_font_selection_dialog_set_font_name (dialog, font_name);
+
+ g_free (font_name);
+
gtk_window_set_transient_for (GTK_WINDOW (dialog),
GTK_WINDOW (get_widget_assert (de->xml,
"data_editor")));
gtk_sheet_show_grid (GTK_SHEET (de->data_sheet[0]), grid_visible);
}
+
+static void
+set_font (GtkWidget *w, gpointer data)
+{
+ PangoFontDescription *font_desc = data;
+ GtkRcStyle *style = gtk_widget_get_modifier_style (w);
+
+ pango_font_description_free (style->font_desc);
+ style->font_desc = pango_font_description_copy (font_desc);
+
+ gtk_widget_modify_style (w, style);
+
+ if ( GTK_IS_CONTAINER (w))
+ gtk_container_foreach (w, set_font, font_desc);
+}
+
void
psppire_data_editor_set_font (PsppireDataEditor *de, PangoFontDescription *font_desc)
{
- psppire_data_store_set_font (de->data_store, font_desc);
- psppire_var_store_set_font (de->var_store, font_desc);
+ set_font (de, font_desc);
+ gtk_container_foreach (GTK_CONTAINER (de), set_font, font_desc);
}
static GObjectClass *parent_class = NULL;
-enum {FONT_CHANGED,
+enum {
BACKEND_CHANGED,
n_SIGNALS};
object_class->finalize = psppire_data_store_finalize;
object_class->dispose = psppire_data_store_dispose;
- signals [FONT_CHANGED] =
- g_signal_new ("font_changed",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_FIRST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
-
signals [BACKEND_CHANGED] =
g_signal_new ("backend-changed",
G_TYPE_FROM_CLASS (class),
data_store->dispose_has_run = FALSE;
}
-const PangoFontDescription *
-psppire_data_store_get_font_desc (const GSheetModel *model,
- glong row, glong column)
-{
- PsppireDataStore *store = PSPPIRE_DATA_STORE (model);
-
- return store->font_desc;
-}
-
static inline gchar *
psppire_data_store_get_string_wrapper (const GSheetModel *model, glong row,
glong column)
iface->is_editable = NULL;
iface->get_foreground = NULL;
iface->get_background = NULL;
- iface->get_font_desc = psppire_data_store_get_font_desc;
iface->get_cell_border = NULL;
iface->get_column_count = psppire_data_store_get_var_count;
iface->get_row_count = psppire_data_store_get_case_count_wrapper;
}
-void
-psppire_data_store_set_font (PsppireDataStore *store,
- const PangoFontDescription *fd)
-{
- g_return_if_fail (store);
- g_return_if_fail (PSPPIRE_IS_DATA_STORE (store));
-
- store->font_desc = fd;
-#if 0
- store->width_of_m = calc_m_width (fd);
-#endif
- g_signal_emit (store, signals [FONT_CHANGED], 0);
-
-
- g_sheet_model_range_changed (G_SHEET_MODEL (store),
- -1, -1, -1, -1);
-}
-
void
psppire_data_store_show_labels (PsppireDataStore *store, gboolean show_labels)
gboolean dispose_has_run ;
PsppireDict *dict;
PsppireCaseFile *case_file;
- const PangoFontDescription *font_desc;
+
/* The width of an upper case 'M' rendered in the current font */
gint width_of_m ;
void psppire_data_store_set_dictionary (PsppireDataStore *data_store,
PsppireDict *dict);
-void psppire_data_store_set_font (PsppireDataStore *store,
- const PangoFontDescription *fd);
-
void psppire_data_store_show_labels (PsppireDataStore *store,
gboolean show_labels);
}
-const PangoFontDescription *
-psppire_var_store_get_font_desc (const GSheetModel *model,
- glong row, glong column)
-{
- PsppireVarStore *store = PSPPIRE_VAR_STORE (model);
-
- return store->font_desc;
-}
-
static gchar *get_column_title (const GSheetModel *model, gint col);
static gchar *get_row_title (const GSheetModel *model, gint row);
static gboolean get_row_sensitivity (const GSheetModel *model, gint row);
iface->is_editable = psppire_var_store_is_editable;
iface->get_foreground = psppire_var_store_get_foreground;
iface->get_background = NULL;
- iface->get_font_desc = psppire_var_store_get_font_desc;
iface->get_cell_border = NULL;
iface->get_justification = NULL;
}
-void
-psppire_var_store_set_font (PsppireVarStore *store, const PangoFontDescription *fd)
-{
- g_return_if_fail (store);
- g_return_if_fail (PSPPIRE_IS_VAR_STORE (store));
-
- store->font_desc = fd;
-
- g_sheet_model_range_changed (G_SHEET_MODEL (store), -1, -1, -1, -1);
-}
-
-
static glong
psppire_var_store_get_row_count (const GSheetModel * model)
{
/*< private >*/
PsppireDict *dict;
GdkColor disabled;
- const PangoFontDescription *font_desc;
gint trailing_rows;
PsppireVarStoreFormatType format_type;
};