[libgda] Don't use GtkStyle or other GTK3 deprecated related drawing functions
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Don't use GtkStyle or other GTK3 deprecated related drawing functions
- Date: Tue, 19 Jul 2011 20:10:08 +0000 (UTC)
commit 7df900b6a0c92334e4d25a2cb5fe2b86fa989a28
Author: Vivien Malerba <malerba gnome-db org>
Date: Tue Jul 19 22:09:55 2011 +0200
Don't use GtkStyle or other GTK3 deprecated related drawing functions
.../data-entries/gdaui-data-cell-renderer-info.c | 67 +++++++------------
libgda-ui/data-entries/gdaui-entry-shell.c | 12 ++--
libgda-ui/internal/utility.c | 39 ++++++------
libgda-ui/internal/utility.h | 2 +-
4 files changed, 52 insertions(+), 68 deletions(-)
---
diff --git a/libgda-ui/data-entries/gdaui-data-cell-renderer-info.c b/libgda-ui/data-entries/gdaui-data-cell-renderer-info.c
index ac6e59b..7e5d162 100644
--- a/libgda-ui/data-entries/gdaui-data-cell-renderer-info.c
+++ b/libgda-ui/data-entries/gdaui-data-cell-renderer-info.c
@@ -374,46 +374,35 @@ gdaui_data_cell_renderer_info_render (GtkCellRenderer *cell,
GdauiDataCellRendererInfo *cellinfo = (GdauiDataCellRendererInfo *) cell;
gint width, height;
gint x_offset, y_offset;
- GtkStateType state = 0;
- static GdkColor **colors = NULL;
- GdkColor *normal = NULL, *prelight = NULL;
- GdkColor *orig_normal, *orig_prelight;
- GtkStyle *style;
+ static GdkRGBA **colors = NULL;
+ GdkRGBA statenormal, stateprelight;
+ GdkRGBA *normal = NULL, *prelight = NULL;
- if (!colors)
- colors = _gdaui_utility_entry_build_info_colors_array ();
- GtkStyle *estyle;
- g_object_get ((GObject*) widget, "style", &estyle, NULL);
- style = gtk_style_copy (estyle);
- g_object_unref (estyle);
+ if (!colors)
+ colors = _gdaui_utility_entry_build_info_colors_array_a ();
- orig_normal = & (style->bg[GTK_STATE_NORMAL]);
- orig_prelight = & (style->bg[GTK_STATE_PRELIGHT]);
- if (cellinfo->priv->attributes & GDA_VALUE_ATTR_IS_NULL) {
- normal = colors[0];
- prelight = colors[1];
+ if (cellinfo->priv->attributes & GDA_VALUE_ATTR_DATA_NON_VALID) {
+ normal = colors[4];
+ prelight = colors[5];
}
-
- if (cellinfo->priv->attributes & GDA_VALUE_ATTR_IS_DEFAULT) {
+ else if (cellinfo->priv->attributes & GDA_VALUE_ATTR_IS_DEFAULT) {
normal = colors[2];
prelight = colors[3];
}
-
- if (cellinfo->priv->attributes & GDA_VALUE_ATTR_DATA_NON_VALID) {
- normal = colors[4];
- prelight = colors[5];
+ else if (cellinfo->priv->attributes & GDA_VALUE_ATTR_IS_NULL) {
+ normal = colors[0];
+ prelight = colors[1];
+ }
+ else {
+ GtkStyleContext *stc;
+ stc = gtk_widget_get_style_context (widget);
+ gtk_style_context_get_background_color (stc, GTK_STATE_FLAG_NORMAL, &statenormal);
+ gtk_style_context_get_background_color (stc, GTK_STATE_FLAG_NORMAL, &stateprelight);
+ normal = &statenormal;
+ prelight = &stateprelight;
}
-
- if (!normal)
- normal = orig_normal;
- if (!prelight)
- prelight = orig_prelight;
-
- style->bg[GTK_STATE_NORMAL] = *normal;
- style->bg[GTK_STATE_ACTIVE] = *normal;
- style->bg[GTK_STATE_PRELIGHT] = *prelight;
gdaui_data_cell_renderer_info_get_size (cell, widget, cell_area,
&x_offset, &y_offset,
@@ -427,17 +416,11 @@ gdaui_data_cell_renderer_info_render (GtkCellRenderer *cell,
if (width <= 0 || height <= 0)
return;
- state = GTK_STATE_NORMAL;
-
- gtk_paint_box (style,
- cr,
- state, GTK_SHADOW_NONE,
- widget, "cellcheck",
- cell_area->x + x_offset + xpad,
- cell_area->y + y_offset + ypad,
- width - 1, height - 1);
-
- g_object_unref (G_OBJECT (style));
+ cairo_set_source_rgba (cr, normal->red, normal->green, normal->blue, normal->alpha);
+ cairo_rectangle (cr, cell_area->x + x_offset + xpad,
+ cell_area->y + y_offset + ypad,
+ width - 1, height - 1);
+ cairo_fill (cr);
}
diff --git a/libgda-ui/data-entries/gdaui-entry-shell.c b/libgda-ui/data-entries/gdaui-entry-shell.c
index 079d2e2..7897ccc 100644
--- a/libgda-ui/data-entries/gdaui-entry-shell.c
+++ b/libgda-ui/data-entries/gdaui-entry-shell.c
@@ -414,13 +414,13 @@ mitem_activated_cb (GtkWidget *mitem, GdauiEntryShell *shell)
static void
gdaui_entry_shell_refresh_status_display (GdauiEntryShell *shell)
{
- static GdkColor **colors = NULL;
- GdkColor *normal = NULL, *prelight = NULL;
+ static GdkRGBA **colors = NULL;
+ GdkRGBA *normal = NULL, *prelight = NULL;
g_return_if_fail (GDAUI_IS_ENTRY_SHELL (shell));
if (!colors)
- colors = _gdaui_utility_entry_build_info_colors_array ();
+ colors = _gdaui_utility_entry_build_info_colors_array_a ();
gtk_widget_set_tooltip_text (shell->priv->button, NULL);
@@ -442,9 +442,9 @@ gdaui_entry_shell_refresh_status_display (GdauiEntryShell *shell)
gtk_widget_set_tooltip_text (shell->priv->button, _("Value is invalid"));
}
- gtk_widget_modify_bg (shell->priv->button, GTK_STATE_NORMAL, normal);
- gtk_widget_modify_bg (shell->priv->button, GTK_STATE_ACTIVE, normal);
- gtk_widget_modify_bg (shell->priv->button, GTK_STATE_PRELIGHT, prelight);
+ gtk_widget_override_background_color (shell->priv->button, GTK_STATE_FLAG_NORMAL, normal);
+ gtk_widget_override_background_color (shell->priv->button, GTK_STATE_FLAG_ACTIVE, normal);
+ gtk_widget_override_background_color (shell->priv->button, GTK_STATE_FLAG_PRELIGHT, prelight);
}
static GdaValueAttribute
diff --git a/libgda-ui/internal/utility.c b/libgda-ui/internal/utility.c
index b9430bf..1a7acb1 100644
--- a/libgda-ui/internal/utility.c
+++ b/libgda-ui/internal/utility.c
@@ -118,9 +118,8 @@ _gdaui_utility_entry_build_actions_menu (GObject *obj_data, guint attrs, GCallba
return menu;
}
-
/*
- * _gdaui_utility_entry_build_info_colors_array
+ * _gdaui_utility_entry_build_info_colors_array_a
*
* Creates an array of colors for the different states of an entry:
* Valid <-> No special color
@@ -132,44 +131,46 @@ _gdaui_utility_entry_build_actions_menu (GObject *obj_data, guint attrs, GCallba
*
* Returns: a new array of 6 colors
*/
-GdkColor **
-_gdaui_utility_entry_build_info_colors_array (void)
+GdkRGBA **
+_gdaui_utility_entry_build_info_colors_array_a (void)
{
- GdkColor **colors;
- GdkColor *color;
+ GdkRGBA **colors;
+ GdkRGBA *color;
- colors = g_new0 (GdkColor *, 6);
+ colors = g_new0 (GdkRGBA *, 6);
/* Green color */
- color = g_new0 (GdkColor, 1);
- gdk_color_parse (GDAUI_COLOR_NORMAL_NULL, color);
+ color = g_new0 (GdkRGBA, 1);
+ g_assert (gdk_rgba_parse (color, GDAUI_COLOR_NORMAL_NULL));
colors[0] = color;
- color = g_new0 (GdkColor, 1);
- gdk_color_parse (GDAUI_COLOR_PRELIGHT_NULL, color);
+ color = g_new0 (GdkRGBA, 1);
+ g_assert (gdk_rgba_parse (color, GDAUI_COLOR_PRELIGHT_NULL));
colors[1] = color;
/* Blue color */
- color = g_new0 (GdkColor, 1);
- gdk_color_parse (GDAUI_COLOR_NORMAL_DEFAULT, color);
+ color = g_new0 (GdkRGBA, 1);
+ g_assert (gdk_rgba_parse (color, GDAUI_COLOR_NORMAL_DEFAULT));
colors[2] = color;
- color = g_new0 (GdkColor, 1);
- gdk_color_parse (GDAUI_COLOR_PRELIGHT_DEFAULT, color);
+ color = g_new0 (GdkRGBA, 1);
+ g_assert (gdk_rgba_parse (color, GDAUI_COLOR_PRELIGHT_DEFAULT));
colors[3] = color;
/* Red color */
- color = g_new0 (GdkColor, 1);
- gdk_color_parse (GDAUI_COLOR_NORMAL_INVALID, color);
+ color = g_new0 (GdkRGBA, 1);
+ g_assert (gdk_rgba_parse (color, GDAUI_COLOR_NORMAL_INVALID));
colors[4] = color;
- color = g_new0 (GdkColor, 1);
- gdk_color_parse (GDAUI_COLOR_PRELIGHT_INVALID, color);
+ color = g_new0 (GdkRGBA, 1);
+ g_assert (gdk_rgba_parse (color, GDAUI_COLOR_PRELIGHT_INVALID));
colors[5] = color;
return colors;
}
+
+
/*
* _gdaui_utility_markup_title
*/
diff --git a/libgda-ui/internal/utility.h b/libgda-ui/internal/utility.h
index 2c91811..6770315 100644
--- a/libgda-ui/internal/utility.h
+++ b/libgda-ui/internal/utility.h
@@ -30,7 +30,7 @@
*
*/
GtkWidget *_gdaui_utility_entry_build_actions_menu (GObject *obj_data, guint attrs, GCallback function);
-GdkColor **_gdaui_utility_entry_build_info_colors_array (void);
+GdkRGBA **_gdaui_utility_entry_build_info_colors_array_a (void);
gchar *_gdaui_utility_markup_title (const gchar *title, gboolean optional);
/*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]