diff options
Diffstat (limited to 'gtk/src')
-rw-r--r-- | gtk/src/ghbcellrenderertext.c | 69 |
1 files changed, 46 insertions, 23 deletions
diff --git a/gtk/src/ghbcellrenderertext.c b/gtk/src/ghbcellrenderertext.c index 6a3a0d26d..19f5e2cc9 100644 --- a/gtk/src/ghbcellrenderertext.c +++ b/gtk/src/ghbcellrenderertext.c @@ -178,10 +178,10 @@ ghb_cell_renderer_text_init (GhbCellRendererText *celltext) priv = GHB_CELL_RENDERER_TEXT_GET_PRIVATE (celltext); - GTK_CELL_RENDERER (celltext)->xalign = 0.0; - GTK_CELL_RENDERER (celltext)->yalign = 0.5; - GTK_CELL_RENDERER (celltext)->xpad = 2; - GTK_CELL_RENDERER (celltext)->ypad = 2; + g_object_set(celltext, "xalign", 0.0, NULL); + g_object_set(celltext, "yalign", 0.5, NULL); + g_object_set(celltext, "xpad", 2, NULL); + g_object_set(celltext, "ypad", 2, NULL); celltext->font_scale = 1.0; celltext->fixed_height_rows = -1; celltext->font = pango_font_description_new (); @@ -1233,9 +1233,9 @@ ghb_cell_renderer_text_set_property (GObject *object, celltext->editable = g_value_get_boolean (value); celltext->editable_set = TRUE; if (celltext->editable) - GTK_CELL_RENDERER (celltext)->mode = GTK_CELL_RENDERER_MODE_EDITABLE; + g_object_set(celltext, "mode", GTK_CELL_RENDERER_MODE_EDITABLE, NULL); else - GTK_CELL_RENDERER (celltext)->mode = GTK_CELL_RENDERER_MODE_INERT; + g_object_set(celltext, "mode", GTK_CELL_RENDERER_MODE_INERT, NULL); g_object_notify (object, "editable-set"); break; @@ -1524,6 +1524,16 @@ get_size (GtkCellRenderer *cell, priv = GHB_CELL_RENDERER_TEXT_GET_PRIVATE (cell); + gint cell_width, cell_height, cell_xpad, cell_ypad; + gfloat cell_xalign, cell_yalign; + g_object_get(cell, + "width", &cell_width, + "height", &cell_height, + "xpad", &cell_xpad, + "ypad", &cell_ypad, + "xalign", &cell_xalign, + "yalign", &cell_yalign, NULL); + if (celltext->calc_fixed_height) { PangoContext *context; @@ -1550,12 +1560,12 @@ get_size (GtkCellRenderer *cell, pango_font_description_free (font_desc); gtk_cell_renderer_set_fixed_size (cell, - cell->width, 2*cell->ypad + + cell_width, 2*cell_ypad + celltext->fixed_height_rows * PANGO_PIXELS (row_height)); if (height) { - *height = cell->height; + *height = cell_height; height = NULL; } celltext->calc_fixed_height = FALSE; @@ -1572,7 +1582,7 @@ get_size (GtkCellRenderer *cell, pango_extents_to_pixels (&rect, NULL); if (height) - *height = cell->ypad * 2 + rect.height; + *height = cell_ypad * 2 + rect.height; /* The minimum size for ellipsized labels is ~ 3 chars */ if (width) @@ -1589,11 +1599,11 @@ get_size (GtkCellRenderer *cell, char_width = pango_font_metrics_get_approximate_char_width (metrics); pango_font_metrics_unref (metrics); - *width = cell->xpad * 2 + (PANGO_PIXELS (char_width) * MAX (priv->width_chars, 3)); + *width = cell_xpad * 2 + (PANGO_PIXELS (char_width) * MAX (priv->width_chars, 3)); } else { - *width = cell->xpad * 2 + rect.x + rect.width; + *width = cell_xpad * 2 + rect.x + rect.width; } } @@ -1602,16 +1612,16 @@ get_size (GtkCellRenderer *cell, if (x_offset) { if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - *x_offset = (1.0 - cell->xalign) * (cell_area->width - (rect.x + rect.width + (2 * cell->xpad))); + *x_offset = (1.0 - cell_xalign) * (cell_area->width - (rect.x + rect.width + (2 * cell_xpad))); else - *x_offset = cell->xalign * (cell_area->width - (rect.x + rect.width + (2 * cell->xpad))); + *x_offset = cell_xalign * (cell_area->width - (rect.x + rect.width + (2 * cell_xpad))); if ((priv->ellipsize_set && priv->ellipsize != PANGO_ELLIPSIZE_NONE) || priv->wrap_width != -1) *x_offset = MAX(*x_offset, 0); } if (y_offset) { - *y_offset = cell->yalign * (cell_area->height - (rect.height + (2 * cell->ypad))); + *y_offset = cell_yalign * (cell_area->height - (rect.height + (2 * cell->ypad))); *y_offset = MAX (*y_offset, 0); } } @@ -1660,7 +1670,14 @@ ghb_cell_renderer_text_render (GtkCellRenderer *cell, layout = get_layout (celltext, widget, TRUE, flags); get_size (cell, widget, cell_area, layout, &x_offset, &y_offset, NULL, NULL); - if (!cell->sensitive) + gboolean sensitive; + gint xpad, ypad; + g_object_get(cell, + "sensitive", &sensitive, + "xpad", &xpad, + "ypad", &ypad, + NULL); + if (!sensitive) { state = GTK_STATE_INSENSITIVE; } @@ -1707,7 +1724,7 @@ ghb_cell_renderer_text_render (GtkCellRenderer *cell, if (priv->ellipsize_set && priv->ellipsize != PANGO_ELLIPSIZE_NONE) pango_layout_set_width (layout, - (cell_area->width - x_offset - 2 * cell->xpad) * PANGO_SCALE); + (cell_area->width - x_offset - 2 * xpad) * PANGO_SCALE); else if (priv->wrap_width == -1) pango_layout_set_width (layout, -1); @@ -1718,8 +1735,8 @@ ghb_cell_renderer_text_render (GtkCellRenderer *cell, expose_area, widget, "cellrenderertext", - cell_area->x + x_offset + cell->xpad, - cell_area->y + y_offset + cell->ypad, + cell_area->x + x_offset + xpad, + cell_area->y + y_offset + ypad, layout); g_object_unref (layout); @@ -1767,9 +1784,11 @@ ghb_cell_renderer_text_editing_done (GtkCellEditable *entry, priv->entry_menu_popdown_timeout = 0; } + gboolean editing_canceled; + g_object_get(entry, "editing-canceled", &editing_canceled, NULL); gtk_cell_renderer_stop_editing (GTK_CELL_RENDERER (data), - GTK_ENTRY (entry)->editing_canceled); - if (GTK_ENTRY (entry)->editing_canceled) + editing_canceled); + if (editing_canceled) return; path = g_object_get_data (G_OBJECT (entry), GHB_CELL_RENDERER_TEXT_PATH); @@ -1843,7 +1862,7 @@ ghb_cell_renderer_text_focus_out_event (GtkWidget *entry, if (priv->in_entry_menu) return FALSE; - GTK_ENTRY (entry)->editing_canceled = TRUE; + g_object_set(entry, "editing-canceled", TRUE, NULL); gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (entry)); gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (entry)); @@ -1871,9 +1890,11 @@ ghb_cell_renderer_text_start_editing (GtkCellRenderer *cell, if (celltext->editable == FALSE) return NULL; + gint xalign; + g_object_get(cell, "xalign", &xalign, NULL); priv->entry = g_object_new (GTK_TYPE_ENTRY, "has-frame", FALSE, - "xalign", cell->xalign, + "xalign", xalign, NULL); if (celltext->text) @@ -1959,8 +1980,10 @@ ghb_cell_renderer_text_set_fixed_height_from_font (GhbCellRendererText *renderer if (number_of_rows == -1) { + gint width; + g_object_get(renderer, "width", &width, NULL); gtk_cell_renderer_set_fixed_size (GTK_CELL_RENDERER (renderer), - GTK_CELL_RENDERER (renderer)->width, + width, -1); } else |