gint *y,
gint *width,
gint *height);
+static void gtk_entry_get_frame_size (GtkEntry *entry,
+ gint *x,
+ gint *y,
+ gint *width,
+ gint *height);
static void get_text_area_size (GtkEntry *entry,
gint *x,
gint *y,
class->toggle_overwrite = gtk_entry_toggle_overwrite;
class->activate = gtk_entry_real_activate;
class->get_text_area_size = gtk_entry_get_text_area_size;
+ class->get_frame_size = gtk_entry_get_frame_size;
quark_inner_border = g_quark_from_static_string ("gtk-entry-inner-border");
quark_password_hint = g_quark_from_static_string ("gtk-entry-password-hint");
icon_info->window = gdk_window_new (gtk_widget_get_window (widget),
&attributes,
attributes_mask);
- gdk_window_set_user_data (icon_info->window, widget);
+ gtk_widget_register_window (widget, icon_info->window);
gtk_widget_queue_resize (widget);
}
&attributes,
attributes_mask);
- gdk_window_set_user_data (priv->text_area, entry);
+ gtk_widget_register_window (widget, priv->text_area);
if (attributes_mask & GDK_WA_CURSOR)
g_object_unref (attributes.cursor);
if (priv->text_area)
{
- gdk_window_set_user_data (priv->text_area, NULL);
+ gtk_widget_unregister_window (widget, priv->text_area);
gdk_window_destroy (priv->text_area);
priv->text_area = NULL;
}
{
if (icon_info->window != NULL)
{
+ gtk_widget_unregister_window (widget, icon_info->window);
gdk_window_destroy (icon_info->window);
icon_info->window = NULL;
}
PangoFontMetrics *metrics;
GtkBorder borders;
PangoContext *context;
- GtkStyleContext *style_context;
- GtkStateFlags state;
gint icon_widths = 0;
gint icon_width, i;
gint width;
context = gtk_widget_get_pango_context (widget);
- style_context = gtk_widget_get_style_context (widget);
- state = gtk_widget_get_state_flags (widget);
-
metrics = pango_context_get_metrics (context,
- gtk_style_context_get_font (style_context, state),
+ pango_context_get_font_description (context),
pango_context_get_language (context));
_gtk_entry_get_borders (entry, &borders);
GtkEntryPrivate *priv = entry->priv;
PangoFontMetrics *metrics;
GtkBorder borders;
- GtkStyleContext *style_context;
- GtkStateFlags state;
PangoContext *context;
gint height;
+ PangoLayout *layout;
+ layout = gtk_entry_ensure_layout (entry, TRUE);
context = gtk_widget_get_pango_context (widget);
- style_context = gtk_widget_get_style_context (widget);
- state = gtk_widget_get_state_flags (widget);
-
metrics = pango_context_get_metrics (context,
- gtk_style_context_get_font (style_context, state),
+ pango_context_get_font_description (context),
pango_context_get_language (context));
priv->ascent = pango_font_metrics_get_ascent (metrics);
priv->descent = pango_font_metrics_get_descent (metrics);
+ pango_font_metrics_unref (metrics);
_gtk_entry_get_borders (entry, &borders);
+ pango_layout_get_pixel_size (layout, NULL, &height);
- height = PANGO_PIXELS (priv->ascent + priv->descent) + borders.top + borders.bottom;
-
- pango_font_metrics_unref (metrics);
+ height += borders.top + borders.bottom;
*minimum = height;
*natural = height;
static void
-get_frame_size (GtkEntry *entry,
- gboolean relative_to_window,
- gint *x,
- gint *y,
- gint *width,
- gint *height)
+gtk_entry_get_frame_size (GtkEntry *entry,
+ gint *x,
+ gint *y,
+ gint *width,
+ gint *height)
{
GtkEntryPrivate *priv = entry->priv;
GtkAllocation allocation;
gtk_widget_get_allocation (widget, &allocation);
if (x)
- *x = relative_to_window ? allocation.x : 0;
+ *x = allocation.x;
if (y)
{
else
*y = (allocation.height - req_height) / 2;
- if (relative_to_window)
- *y += allocation.y;
+ *y += allocation.y;
}
if (width)
}
}
+static void
+get_frame_size (GtkEntry *entry,
+ gboolean relative_to_window,
+ gint *x,
+ gint *y,
+ gint *width,
+ gint *height)
+{
+ GtkEntryClass *class;
+ GtkWidget *widget = GTK_WIDGET (entry);
+
+ g_return_if_fail (GTK_IS_ENTRY (entry));
+
+ class = GTK_ENTRY_GET_CLASS (entry);
+
+ if (class->get_frame_size)
+ class->get_frame_size (entry, x, y, width, height);
+
+ if (!relative_to_window)
+ {
+ GtkAllocation allocation;
+ gtk_widget_get_allocation (widget, &allocation);
+
+ if (x)
+ *x -= allocation.x;
+ if (y)
+ *y -= allocation.y;
+ }
+}
+
static void
gtk_entry_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
GtkEntryPrivate *priv = entry->priv;
int i;
- context = gtk_widget_get_style_context (widget);
+ if (gtk_cairo_should_draw_window (cr,
+ gtk_widget_get_window (widget)))
+ {
+ context = gtk_widget_get_style_context (widget);
- /* Draw entry_bg, shadow, progress and focus */
- gtk_entry_draw_frame (widget, context, cr);
+ /* Draw entry_bg, shadow, progress and focus */
+ gtk_entry_draw_frame (widget, context, cr);
- /* Draw text and cursor */
- cairo_save (cr);
+ /* Draw text and cursor */
+ cairo_save (cr);
- gtk_cairo_transform_to_window (cr, widget, priv->text_area);
+ gtk_cairo_transform_to_window (cr, widget, priv->text_area);
- if (priv->dnd_position != -1)
- gtk_entry_draw_cursor (GTK_ENTRY (widget), cr, CURSOR_DND);
-
- gtk_entry_draw_text (GTK_ENTRY (widget), cr);
+ if (priv->dnd_position != -1)
+ gtk_entry_draw_cursor (GTK_ENTRY (widget), cr, CURSOR_DND);
- /* When no text is being displayed at all, don't show the cursor */
- if (gtk_entry_get_display_mode (entry) != DISPLAY_BLANK &&
- gtk_widget_has_focus (widget) &&
- priv->selection_bound == priv->current_pos && priv->cursor_visible)
- gtk_entry_draw_cursor (GTK_ENTRY (widget), cr, CURSOR_STANDARD);
+ gtk_entry_draw_text (GTK_ENTRY (widget), cr);
- cairo_restore (cr);
+ /* When no text is being displayed at all, don't show the cursor */
+ if (gtk_entry_get_display_mode (entry) != DISPLAY_BLANK &&
+ gtk_widget_has_focus (widget) &&
+ priv->selection_bound == priv->current_pos && priv->cursor_visible)
+ gtk_entry_draw_cursor (GTK_ENTRY (widget), cr, CURSOR_STANDARD);
- /* Draw icons */
- for (i = 0; i < MAX_ICONS; i++)
- {
- EntryIconInfo *icon_info = priv->icons[i];
+ cairo_restore (cr);
- if (icon_info != NULL)
- draw_icon (widget, cr, i);
+ /* Draw icons */
+ for (i = 0; i < MAX_ICONS; i++)
+ {
+ EntryIconInfo *icon_info = priv->icons[i];
+
+ if (icon_info != NULL)
+ draw_icon (widget, cr, i);
+ }
}
return FALSE;
gtk_entry_update_cached_style_values (entry);
- gtk_entry_recompute (entry);
-
icon_theme_changed (entry);
}
layout = gtk_entry_ensure_layout (entry, TRUE);
- gtk_entry_get_text_area_size (entry, NULL, NULL, &area_width, &area_height);
+ get_text_area_size (entry, NULL, NULL, &area_width, &area_height);
area_height = PANGO_SCALE * area_height;
line = pango_layout_get_lines_readonly (layout)->data;
GtkAdjustment *adjustment;
PangoContext *context;
PangoFontMetrics *metrics;
- GtkStyleContext *style_context;
- GtkStateFlags state;
GtkBorder borders;
gint x, layout_x;
gint char_width;
/* Approximate width of a char, so user can see what is ahead/behind */
context = gtk_widget_get_pango_context (widget);
- style_context = gtk_widget_get_style_context (widget);
- state = gtk_widget_get_state_flags (widget);
metrics = pango_context_get_metrics (context,
- gtk_style_context_get_font (style_context, state),
+ pango_context_get_font_description (context),
pango_context_get_language (context));
char_width = pango_font_metrics_get_approximate_char_width (metrics) / PANGO_SCALE;
icon_info->tooltip = tooltip ? g_markup_escape_text (tooltip, -1) : NULL;
ensure_has_tooltip (entry);
+
+ g_object_notify (G_OBJECT (entry),
+ icon_pos == GTK_ENTRY_ICON_PRIMARY ? "primary-icon-tooltip-text" : "secondary-icon-tooltip-text");
}
/**