From: John Darrington Date: Tue, 18 Nov 2008 23:57:59 +0000 (+0900) Subject: Made everything except gtkitementry.c multi-head safe X-Git-Tag: v0.7.1~144^2~1 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=88eb1ede60522d3893dfe1c75cbab2d03f5cb2d5;p=pspp-builds.git Made everything except gtkitementry.c multi-head safe --- diff --git a/lib/gtksheet/automake.mk b/lib/gtksheet/automake.mk index d6bb3cdc..ee523670 100644 --- a/lib/gtksheet/automake.mk +++ b/lib/gtksheet/automake.mk @@ -2,7 +2,7 @@ noinst_LIBRARIES += lib/gtksheet/libgtksheet.a -lib_gtksheet_libgtksheet_a_CFLAGS = $(GTK_CFLAGS) -Wall +lib_gtksheet_libgtksheet_a_CFLAGS = $(GTK_CFLAGS) -Wall -DGDK_MULTIHEAD_SAFE=1 lib_gtksheet_libgtksheet_a_SOURCES = \ diff --git a/lib/gtksheet/gsheetmodel.c b/lib/gtksheet/gsheetmodel.c index 0d1a3f56..f06dc638 100644 --- a/lib/gtksheet/gsheetmodel.c +++ b/lib/gtksheet/gsheetmodel.c @@ -377,9 +377,9 @@ g_sheet_model_is_visible (const GSheetModel *model, * @column: The column * * Returns the foreground colour of the cell at @row, @column - * Returns: the foreground colour, or NULL on error. + * The color is unallocated. It will be allocated by the viewing object. **/ -const GdkColor * +GdkColor * g_sheet_model_get_foreground (const GSheetModel *model, glong row, glong column) { @@ -399,9 +399,9 @@ g_sheet_model_get_foreground (const GSheetModel *model, * @column: The column * * Returns the background colour of the cell at @row, @column - * Returns: the background colour, or NULL on error. + * The color is unallocated. It will be allocated by the viewing object. **/ -const GdkColor * +GdkColor * g_sheet_model_get_background (const GSheetModel *model, glong row, glong column) { diff --git a/lib/gtksheet/gsheetmodel.h b/lib/gtksheet/gsheetmodel.h index 6d60e032..ae5a372b 100644 --- a/lib/gtksheet/gsheetmodel.h +++ b/lib/gtksheet/gsheetmodel.h @@ -107,10 +107,10 @@ struct _GSheetModelIface gboolean (* is_visible) (const GSheetModel *sheet_model, glong row, glong column); gboolean (* is_editable) (const GSheetModel *sheet_model, glong row, glong column); - const GdkColor * (* get_foreground) (const GSheetModel *sheet_model, - glong row, glong column); + GdkColor * (* get_foreground) (const GSheetModel *sheet_model, + glong row, glong column); - const GdkColor * (* get_background) (const GSheetModel *sheet_model, + GdkColor * (* get_background) (const GSheetModel *sheet_model, glong row, glong column); const GtkJustification * (* get_justification) (const GSheetModel *sheet_model, @@ -169,10 +169,10 @@ inline gboolean g_sheet_model_is_visible (const GSheetModel *model, glong row, glong column); -inline const GdkColor *g_sheet_model_get_foreground - (const GSheetModel *model, glong row, glong column); +inline GdkColor *g_sheet_model_get_foreground + (const GSheetModel *model, glong row, glong column); -inline const GdkColor *g_sheet_model_get_background +inline GdkColor *g_sheet_model_get_background (const GSheetModel *model, glong row, glong column); diff --git a/lib/gtksheet/gtkitementry.c b/lib/gtksheet/gtkitementry.c index efc22e2e..0ee90cc8 100644 --- a/lib/gtksheet/gtkitementry.c +++ b/lib/gtksheet/gtkitementry.c @@ -1,3 +1,4 @@ +#undef GDK_MULTIHEAD_SAFE /* GTK - The GIMP Toolkit * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald * diff --git a/lib/gtksheet/gtksheet.c b/lib/gtksheet/gtksheet.c index 79ba35dc..69b55174 100644 --- a/lib/gtksheet/gtksheet.c +++ b/lib/gtksheet/gtksheet.c @@ -548,12 +548,6 @@ static void gtk_sheet_button_size_request (GtkSheet *sheet, const GtkSheetButton *button, GtkRequisition *requisition); -/* Attributes routines */ -static void init_attributes (const GtkSheet *sheet, - gint col, - GtkSheetCellAttr *attributes); - - /* Memory allocation routines */ static void gtk_sheet_real_cell_clear (GtkSheet *sheet, gint row, @@ -5594,72 +5588,64 @@ gtk_sheet_set_row_height (GtkSheet *sheet, g_signal_emit (sheet, sheet_signals[CHANGED], 0, row, - 1); } + gboolean gtk_sheet_get_attributes (const GtkSheet *sheet, gint row, gint col, - GtkSheetCellAttr *attributes) + GtkSheetCellAttr *attr) { - const GdkColor *fg, *bg; + GdkColor *fg, *bg; const GtkJustification *j ; const PangoFontDescription *font_desc ; const GtkSheetCellBorder *border ; + GdkColormap *colormap; g_return_val_if_fail (sheet != NULL, FALSE); g_return_val_if_fail (GTK_IS_SHEET (sheet), FALSE); if (row < 0 || col < 0) return FALSE; - init_attributes (sheet, col, attributes); + attr->foreground = GTK_WIDGET (sheet)->style->black; + attr->background = sheet->color[BG_COLOR]; - if ( !sheet->model) - return FALSE; + attr->border.width = 0; + attr->border.line_style = GDK_LINE_SOLID; + attr->border.cap_style = GDK_CAP_NOT_LAST; + 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; - attributes->is_editable = g_sheet_model_is_editable (sheet->model, row, col); - attributes->is_visible = g_sheet_model_is_visible (sheet->model, row, col); + attr->is_editable = g_sheet_model_is_editable (sheet->model, row, col); + attr->is_visible = g_sheet_model_is_visible (sheet->model, row, col); + colormap = gtk_widget_get_colormap (GTK_WIDGET (sheet)); fg = g_sheet_model_get_foreground (sheet->model, row, col); if ( fg ) - attributes->foreground = *fg; + { + gdk_colormap_alloc_color (colormap, fg, TRUE, TRUE); + attr->foreground = *fg; + } bg = g_sheet_model_get_background (sheet->model, row, col); if ( bg ) - attributes->background = *bg; + { + gdk_colormap_alloc_color (colormap, bg, TRUE, TRUE); + attr->background = *bg; + } j = g_sheet_model_get_justification (sheet->model, row, col); - attributes->justification = j ? *j : GTK_JUSTIFY_LEFT; + attr->justification = j ? *j : GTK_JUSTIFY_LEFT; font_desc = g_sheet_model_get_font_desc (sheet->model, row, col); - if ( font_desc ) attributes->font_desc = font_desc; + if ( font_desc ) attr->font_desc = font_desc; border = g_sheet_model_get_cell_border (sheet->model, row, col); - if ( border ) attributes->border = *border; + if ( border ) attr->border = *border; return TRUE; } -static void -init_attributes (const GtkSheet *sheet, gint col, GtkSheetCellAttr *attributes) -{ - /* DEFAULT VALUES */ - attributes->foreground = GTK_WIDGET (sheet)->style->black; - attributes->background = sheet->color[BG_COLOR]; - if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) - { - attributes->background = sheet->color[BG_COLOR]; - } - attributes->justification = g_sheet_column_get_justification (sheet->column_geometry, col); - attributes->border.width = 0; - attributes->border.line_style = GDK_LINE_SOLID; - attributes->border.cap_style = GDK_CAP_NOT_LAST; - attributes->border.join_style = GDK_JOIN_MITER; - attributes->border.mask = 0; - attributes->border.color = GTK_WIDGET (sheet)->style->black; - attributes->is_editable = TRUE; - attributes->is_visible = TRUE; - attributes->font_desc = GTK_WIDGET (sheet)->style->font_desc; -} - - static void gtk_sheet_button_size_request (GtkSheet *sheet, const GtkSheetButton *button, diff --git a/src/ui/gui/automake.mk b/src/ui/gui/automake.mk index f77f88c7..9ac7050c 100644 --- a/src/ui/gui/automake.mk +++ b/src/ui/gui/automake.mk @@ -3,7 +3,7 @@ bin_PROGRAMS += src/ui/gui/psppire src_ui_gui_psppire_CFLAGS = $(GTK_CFLAGS) $(GLADE_CFLAGS) -Wall \ - -DINSTALLDIR=\"$(bindir)\" + -DINSTALLDIR=\"$(bindir)\" -DGDK_MULTIHEAD_SAFE=1 src_ui_gui_psppire_LDFLAGS = \ diff --git a/src/ui/gui/psppire-data-store.c b/src/ui/gui/psppire-data-store.c index dee18378..9f7e4075 100644 --- a/src/ui/gui/psppire-data-store.c +++ b/src/ui/gui/psppire-data-store.c @@ -235,13 +235,6 @@ psppire_data_store_sheet_model_init (GSheetModelIface *iface) iface->get_row_count = psppire_data_store_get_case_count_wrapper; } -static -gboolean always_true () -{ - return TRUE; -} - - static void delete_cases_callback (GtkWidget *w, casenumber first, casenumber n_cases, gpointer data) diff --git a/src/ui/gui/psppire-var-store.c b/src/ui/gui/psppire-var-store.c index 8fe5fc66..eb18f2c4 100644 --- a/src/ui/gui/psppire-var-store.c +++ b/src/ui/gui/psppire-var-store.c @@ -239,14 +239,12 @@ psppire_var_store_class_init (PsppireVarStoreClass *class) pspec); } +#define DISABLED_COLOR "pink" static void psppire_var_store_init (PsppireVarStore *var_store) { - GdkColormap *colormap = gdk_colormap_get_system (); - - g_assert (gdk_color_parse ("gray", &var_store->disabled)); - - gdk_colormap_alloc_color (colormap, &var_store->disabled, FALSE, TRUE); + if ( ! gdk_color_parse (DISABLED_COLOR, &var_store->disabled)) + g_critical ("Could not parse color \"%s\"", DISABLED_COLOR); var_store->dict = 0; var_store->trailing_rows = 40; @@ -827,13 +825,6 @@ geometry_is_sensitive (const GSheetRow *geom, glong row) return row < psppire_dict_get_var_cnt (vs->dict); } -static -gboolean always_true () -{ - return TRUE; -} - - static gchar * geometry_get_button_label (const GSheetRow *geom, glong unit) {