#include <math.h>
#include <string.h>
-#include "gdk/gdkkeysyms.h"
#include "gtkalignment.h"
#include "gtkbindings.h"
#include "gtkcelleditable.h"
#include "gtkwindow.h"
#include "gtktreeview.h"
#include "gtktreeselection.h"
+#include "gtktypebuiltins.h"
#include "gtkprivate.h"
#include "gtkentryprivate.h"
#include "gtkcelllayout.h"
#include "gtktooltip.h"
#include "gtkiconfactory.h"
#include "gtkicontheme.h"
-
+#include "gtkwidgetprivate.h"
+#include "gtkstylecontextprivate.h"
/**
* SECTION:gtkentry
static void gtk_entry_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_entry_draw_frame (GtkWidget *widget,
+ GtkStyleContext *context,
cairo_t *cr);
static void gtk_entry_draw_progress (GtkWidget *widget,
+ GtkStyleContext *context,
cairo_t *cr);
static gint gtk_entry_draw (GtkWidget *widget,
cairo_t *cr);
static gint gtk_entry_focus_out (GtkWidget *widget,
GdkEventFocus *event);
static void gtk_entry_grab_focus (GtkWidget *widget);
-static void gtk_entry_style_set (GtkWidget *widget,
- GtkStyle *previous_style);
+static void gtk_entry_style_updated (GtkWidget *widget);
static gboolean gtk_entry_query_tooltip (GtkWidget *widget,
gint x,
gint y,
GtkTooltip *tooltip);
static void gtk_entry_direction_changed (GtkWidget *widget,
GtkTextDirection previous_dir);
-static void gtk_entry_state_changed (GtkWidget *widget,
- GtkStateType previous_state);
+static void gtk_entry_state_flags_changed (GtkWidget *widget,
+ GtkStateFlags previous_state);
static void gtk_entry_screen_changed (GtkWidget *widget,
GdkScreen *old_screen);
static PangoLayout *gtk_entry_ensure_layout (GtkEntry *entry,
gboolean include_preedit);
static void gtk_entry_reset_layout (GtkEntry *entry);
-static void gtk_entry_queue_draw (GtkEntry *entry);
static void gtk_entry_recompute (GtkEntry *entry);
static gint gtk_entry_find_position (GtkEntry *entry,
gint x);
widget_class->focus_in_event = gtk_entry_focus_in;
widget_class->focus_out_event = gtk_entry_focus_out;
widget_class->grab_focus = gtk_entry_grab_focus;
- widget_class->style_set = gtk_entry_style_set;
+ widget_class->style_updated = gtk_entry_style_updated;
widget_class->query_tooltip = gtk_entry_query_tooltip;
widget_class->drag_begin = gtk_entry_drag_begin;
widget_class->drag_end = gtk_entry_drag_end;
widget_class->direction_changed = gtk_entry_direction_changed;
- widget_class->state_changed = gtk_entry_state_changed;
+ widget_class->state_flags_changed = gtk_entry_state_flags_changed;
widget_class->screen_changed = gtk_entry_screen_changed;
widget_class->mnemonic_activate = gtk_entry_mnemonic_activate;
g_param_spec_boolean ("primary-icon-activatable",
P_("Primary icon activatable"),
P_("Whether the primary icon is activatable"),
- FALSE,
+ TRUE,
GTK_PARAM_READWRITE));
/**
g_param_spec_boolean ("secondary-icon-activatable",
P_("Secondary icon activatable"),
P_("Whether the secondary icon is activatable"),
- FALSE,
+ TRUE,
GTK_PARAM_READWRITE));
{
GtkEntry *entry = GTK_ENTRY (object);
GtkEntryPrivate *priv = entry->priv;
- GtkWidget *widget;
switch (prop_id)
{
if (new_value != priv->editable)
{
- widget = GTK_WIDGET (entry);
+ GtkWidget *widget = GTK_WIDGET (entry);
+
if (!new_value)
{
_gtk_entry_reset_im_context (entry);
if (new_value && gtk_widget_has_focus (widget))
gtk_im_context_focus_in (priv->im_context);
- gtk_entry_queue_draw (entry);
+ gtk_widget_queue_draw (widget);
}
}
break;
0x273a /* SIXTEEN POINTED ASTERISK */
};
- if (gtk_widget_get_style (widget))
- gtk_widget_style_get (widget,
- "invisible-char", &invisible_chars[0],
- NULL);
+ gtk_widget_style_get (widget,
+ "invisible-char", &invisible_chars[0],
+ NULL);
layout = gtk_widget_create_pango_layout (widget, NULL);
static void
gtk_entry_init (GtkEntry *entry)
{
+ GtkStyleContext *context;
GtkEntryPrivate *priv;
entry->priv = G_TYPE_INSTANCE_GET_PRIVATE (entry,
g_signal_connect (priv->im_context, "delete-surrounding",
G_CALLBACK (gtk_entry_delete_surrounding_cb), entry);
+ context = gtk_widget_get_style_context (GTK_WIDGET (entry));
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_ENTRY);
}
static gint
display = gtk_widget_get_display (widget);
cursor = gdk_cursor_new_for_display (display, GDK_XTERM);
gdk_window_set_cursor (icon_info->window, cursor);
- gdk_cursor_unref (cursor);
+ g_object_unref (cursor);
}
else
{
GTK_WIDGET_CLASS (gtk_entry_parent_class)->map (widget);
+ gdk_window_show (priv->text_area);
+
for (i = 0; i < MAX_ICONS; i++)
{
if ((icon_info = priv->icons[i]) != NULL)
}
}
+ gdk_window_hide (priv->text_area);
+
GTK_WIDGET_CLASS (gtk_entry_parent_class)->unmap (widget);
}
gdk_window_set_user_data (priv->text_area, entry);
if (attributes_mask & GDK_WA_CURSOR)
- gdk_cursor_unref (attributes.cursor);
-
- gtk_widget_style_attach (widget);
-
- gdk_window_show (priv->text_area);
+ g_object_unref (attributes.cursor);
gtk_im_context_set_client_window (priv->im_context, priv->text_area);
{
GtkEntryPrivate *priv = entry->priv;
GtkWidget *widget = GTK_WIDGET (entry);
- GtkStyle *style;
if (priv->has_frame)
{
- style = gtk_widget_get_style (widget);
+ GtkStyleContext *context;
+ GtkBorder padding;
- *xborder = style->xthickness;
- *yborder = style->ythickness;
+ context = gtk_widget_get_style_context (widget);
+ gtk_style_context_get_padding (context, 0, &padding);
+
+ *xborder = padding.left;
+ *yborder = padding.top;
}
else
{
gint xborder, yborder;
GtkBorder inner_border;
PangoContext *context;
+ GtkStyleContext *style_context;
+ GtkStateFlags state;
gint icon_widths = 0;
gint icon_width, i;
gint width;
- gtk_widget_ensure_style (widget);
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_widget_get_style (widget)->font_desc,
+ gtk_style_context_get_font (style_context, state),
pango_context_get_language (context));
_gtk_entry_get_borders (entry, &xborder, &yborder);
PangoFontMetrics *metrics;
gint xborder, yborder;
GtkBorder inner_border;
+ GtkStyleContext *style_context;
+ GtkStateFlags state;
PangoContext *context;
gint height;
- gtk_widget_ensure_style (widget);
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_widget_get_style (widget)->font_desc,
+ gtk_style_context_get_font (style_context, state),
pango_context_get_language (context));
priv->ascent = pango_font_metrics_get_ascent (metrics);
}
}
-/* Kudos to the gnome-panel guys. */
-static void
-colorshift_pixbuf (GdkPixbuf *dest,
- GdkPixbuf *src,
- gint shift)
-{
- gint i, j;
- gint width, height, has_alpha, src_rowstride, dest_rowstride;
- guchar *target_pixels;
- guchar *original_pixels;
- guchar *pix_src;
- guchar *pix_dest;
- int val;
- guchar r, g, b;
-
- has_alpha = gdk_pixbuf_get_has_alpha (src);
- width = gdk_pixbuf_get_width (src);
- height = gdk_pixbuf_get_height (src);
- src_rowstride = gdk_pixbuf_get_rowstride (src);
- dest_rowstride = gdk_pixbuf_get_rowstride (dest);
- original_pixels = gdk_pixbuf_get_pixels (src);
- target_pixels = gdk_pixbuf_get_pixels (dest);
-
- for (i = 0; i < height; i++)
- {
- pix_dest = target_pixels + i * dest_rowstride;
- pix_src = original_pixels + i * src_rowstride;
-
- for (j = 0; j < width; j++)
- {
- r = *(pix_src++);
- g = *(pix_src++);
- b = *(pix_src++);
-
- val = r + shift;
- *(pix_dest++) = CLAMP (val, 0, 255);
-
- val = g + shift;
- *(pix_dest++) = CLAMP (val, 0, 255);
-
- val = b + shift;
- *(pix_dest++) = CLAMP (val, 0, 255);
-
- if (has_alpha)
- *(pix_dest++) = *(pix_src++);
- }
- }
-}
-
static gboolean
should_prelight (GtkEntry *entry,
GtkEntryIconPosition icon_pos)
EntryIconInfo *icon_info = priv->icons[icon_pos];
gboolean prelight;
- if (!icon_info)
+ if (!icon_info)
return FALSE;
if (icon_info->nonactivatable && icon_info->target_list == NULL)
EntryIconInfo *icon_info = priv->icons[icon_pos];
GdkPixbuf *pixbuf;
gint x, y, width, height;
+ GtkStyleContext *context;
+ GtkIconSource *icon_source;
+ GtkStateFlags state;
if (!icon_info)
return;
x = (width - gdk_pixbuf_get_width (pixbuf)) / 2;
y = (height - gdk_pixbuf_get_height (pixbuf)) / 2;
- if (!gtk_widget_is_sensitive (widget) ||
- icon_info->insensitive)
- {
- GdkPixbuf *temp_pixbuf;
+ icon_source = gtk_icon_source_new ();
+ gtk_icon_source_set_pixbuf (icon_source, pixbuf);
+ gtk_icon_source_set_state_wildcarded (icon_source, TRUE);
- temp_pixbuf = gdk_pixbuf_copy (pixbuf);
- gdk_pixbuf_saturate_and_pixelate (pixbuf,
- temp_pixbuf,
- 0.8f,
- TRUE);
- g_object_unref (pixbuf);
- pixbuf = temp_pixbuf;
- }
+ state = 0;
+ if (!gtk_widget_is_sensitive (widget) || icon_info->insensitive)
+ state |= GTK_STATE_FLAG_INSENSITIVE;
else if (icon_info->prelight)
- {
- GdkPixbuf *temp_pixbuf;
+ state |= GTK_STATE_FLAG_PRELIGHT;
- temp_pixbuf = gdk_pixbuf_copy (pixbuf);
- colorshift_pixbuf (temp_pixbuf, pixbuf, 30);
- g_object_unref (pixbuf);
- pixbuf = temp_pixbuf;
- }
+ context = gtk_widget_get_style_context (widget);
+ gtk_style_context_save (context);
+ gtk_style_context_set_state (context, state);
+ pixbuf = gtk_render_icon_pixbuf (context, icon_source, (GtkIconSize)-1);
+ gtk_style_context_restore (context);
+
+ gtk_icon_source_free (icon_source);
gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y);
cairo_paint (cr);
static void
-gtk_entry_draw_frame (GtkWidget *widget,
- cairo_t *cr)
+gtk_entry_draw_frame (GtkWidget *widget,
+ GtkStyleContext *context,
+ cairo_t *cr)
{
GtkEntry *entry = GTK_ENTRY (widget);
GtkEntryPrivate *priv = entry->priv;
- GtkStyle *style;
- GdkWindow *window;
gint x = 0, y = 0, width, height;
- GtkStateType state;
GtkAllocation allocation;
gint frame_x, frame_y;
cairo_save (cr);
- window = gtk_widget_get_window (widget);
-
get_frame_size (GTK_ENTRY (widget), &frame_x, &frame_y, &width, &height);
gtk_widget_get_allocation (widget, &allocation);
height -= 2 * priv->focus_width;
}
- style = gtk_widget_get_style (widget);
- state = gtk_widget_has_focus (widget) ?
- GTK_STATE_ACTIVE : gtk_widget_get_state (widget);
-
- gtk_paint_flat_box (style, cr,
- state, GTK_SHADOW_NONE,
- widget, "entry_bg",
- x, y, width, height);
+ gtk_render_background (context, cr,
+ x, y, width, height);
if (priv->has_frame)
- gtk_paint_shadow (style, cr,
- state, priv->shadow_type,
- widget, "entry", x, y, width, height);
+ gtk_render_frame (context, cr,
+ x, y, width, height);
- gtk_entry_draw_progress (widget, cr);
+ gtk_entry_draw_progress (widget, context, cr);
if (gtk_widget_has_focus (widget) && !priv->interior_focus)
{
width += 2 * priv->focus_width;
height += 2 * priv->focus_width;
- gtk_paint_focus (style, cr,
- gtk_widget_get_state (widget),
- widget, "entry",
- 0, 0, width, height);
+ gtk_render_focus (context, cr,
+ 0, 0, width, height);
}
cairo_restore (cr);
}
static void
-gtk_entry_draw_progress (GtkWidget *widget,
- cairo_t *cr)
+gtk_entry_draw_progress (GtkWidget *widget,
+ GtkStyleContext *context,
+ cairo_t *cr)
{
gint x, y, width, height;
- GtkStateType state;
get_progress_area (widget, &x, &y, &width, &height);
if ((width <= 0) || (height <= 0))
return;
- state = GTK_STATE_SELECTED;
- if (!gtk_widget_get_sensitive (widget))
- state = GTK_STATE_INSENSITIVE;
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR);
- gtk_paint_box (gtk_widget_get_style (widget), cr,
- state, GTK_SHADOW_OUT,
- widget, "entry-progress",
- x, y,
- width, height);
+ gtk_render_activity (context, cr,
+ x, y, width, height);
+
+ gtk_style_context_restore (context);
}
static gint
cairo_t *cr)
{
GtkEntry *entry = GTK_ENTRY (widget);
- GtkStyle *style;
- GtkStateType state;
+ GtkStyleContext *context;
+ GtkStateFlags state;
GtkEntryPrivate *priv = entry->priv;
int i;
- style = gtk_widget_get_style (widget);
+ context = gtk_widget_get_style_context (widget);
+ state = gtk_widget_get_state_flags (widget);
- state = gtk_widget_has_focus (widget) ?
- GTK_STATE_ACTIVE : gtk_widget_get_state (widget);
+ gtk_style_context_save (context);
+ gtk_style_context_set_state (context, state);
if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)))
{
/* Draw entry_bg, shadow, progress and focus */
- gtk_entry_draw_frame (widget, cr);
+ gtk_entry_draw_frame (widget, context, cr);
/* Draw text and cursor */
cairo_save (cr);
}
}
+ gtk_style_context_restore (context);
+
return FALSE;
}
GtkEntry *entry = GTK_ENTRY (widget);
GtkEntryPrivate *priv = entry->priv;
EntryIconInfo *icon_info = NULL;
- GdkDragContext *context;
gint tmp_pos;
gint i;
{
icon_info->in_drag = TRUE;
icon_info->pressed = FALSE;
- context = gtk_drag_begin (widget,
- icon_info->target_list,
- icon_info->actions,
- 1,
- (GdkEvent*)event);
+ gtk_drag_begin (widget,
+ icon_info->target_list,
+ icon_info->actions,
+ 1,
+ (GdkEvent*)event);
}
return TRUE;
if (priv->mouse_cursor_obscured)
{
GdkCursor *cursor;
-
+
cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), GDK_XTERM);
gdk_window_set_cursor (priv->text_area, cursor);
- gdk_cursor_unref (cursor);
+ g_object_unref (cursor);
priv->mouse_cursor_obscured = FALSE;
}
gdk_window_set_cursor (window, cursor);
- gdk_cursor_unref (cursor);
+ g_object_unref (cursor);
}
static void
}
static void
-gtk_entry_state_changed (GtkWidget *widget,
- GtkStateType previous_state)
+gtk_entry_state_flags_changed (GtkWidget *widget,
+ GtkStateFlags previous_state)
{
GtkEntry *entry = GTK_ENTRY (widget);
GtkEntryPrivate *priv = entry->priv;
gdk_window_set_cursor (priv->text_area, cursor);
if (cursor)
- gdk_cursor_unref (cursor);
+ g_object_unref (cursor);
priv->mouse_cursor_obscured = FALSE;
}
static void
-gtk_entry_style_set (GtkWidget *widget,
- GtkStyle *previous_style)
+gtk_entry_style_updated (GtkWidget *widget)
{
GtkEntry *entry = GTK_ENTRY (widget);
GtkEntryPrivate *priv = entry->priv;
gint focus_width;
gboolean interior_focus;
+ GTK_WIDGET_CLASS (gtk_entry_parent_class)->style_updated (widget);
+
gtk_widget_style_get (widget,
"focus-line-width", &focus_width,
"interior-focus", &interior_focus,
if (gtk_widget_has_screen (GTK_WIDGET (entry)))
{
gtk_entry_adjust_scroll (entry);
- gtk_entry_queue_draw (entry);
-
+ gtk_widget_queue_draw (GTK_WIDGET (entry));
+
update_im_cursor_location (entry);
}
}
static void
-draw_text_with_color (GtkEntry *entry, cairo_t *cr, GdkColor *default_color)
+draw_text_with_color (GtkEntry *entry,
+ cairo_t *cr,
+ GdkRGBA *default_color)
{
GtkEntryPrivate *priv = entry->priv;
PangoLayout *layout = gtk_entry_ensure_layout (entry, TRUE);
get_layout_position (entry, &x, &y);
cairo_move_to (cr, x, y);
- gdk_cairo_set_source_color (cr, default_color);
+ gdk_cairo_set_source_rgba (cr, default_color);
pango_cairo_show_layout (cr, layout);
if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start_pos, &end_pos))
gint *ranges;
gint n_ranges, i;
PangoRectangle logical_rect;
- GdkColor *selection_color, *text_color;
+ GdkRGBA selection_color, text_color;
GtkBorder inner_border;
- GtkStyle *style;
+ GtkStyleContext *context;
+ GtkStateFlags state;
+ context = gtk_widget_get_style_context (widget);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
gtk_entry_get_pixel_ranges (entry, &ranges, &n_ranges);
- style = gtk_widget_get_style (widget);
+ state = GTK_STATE_FLAG_SELECTED;
if (gtk_widget_has_focus (widget))
- {
- selection_color = &style->base [GTK_STATE_SELECTED];
- text_color = &style->text [GTK_STATE_SELECTED];
- }
- else
- {
- selection_color = &style->base [GTK_STATE_ACTIVE];
- text_color = &style->text [GTK_STATE_ACTIVE];
- }
+ state |= GTK_STATE_FLAG_FOCUSED;
+
+ gtk_style_context_get_background_color (context, state, &selection_color);
+ gtk_style_context_get_color (context, state, &text_color);
_gtk_entry_effective_inner_border (entry, &inner_border);
cairo_clip (cr);
- gdk_cairo_set_source_color (cr, selection_color);
+ gdk_cairo_set_source_rgba (cr, &selection_color);
cairo_paint (cr);
cairo_move_to (cr, x, y);
- gdk_cairo_set_source_color (cr, text_color);
+ gdk_cairo_set_source_rgba (cr, &text_color);
pango_cairo_show_layout (cr, layout);
g_free (ranges);
{
GtkEntryPrivate *priv = entry->priv;
GtkWidget *widget = GTK_WIDGET (entry);
- GtkStateType state;
- GtkStyle *style;
- GdkColor text_color, bar_text_color;
+ GtkStateFlags state = 0;
+ GdkRGBA text_color, bar_text_color;
+ GtkStyleContext *context;
gint pos_x, pos_y;
gint width, height;
gint progress_x, progress_y, progress_width, progress_height;
/* Nothing to display at all */
if (gtk_entry_get_display_mode (entry) == DISPLAY_BLANK)
return;
-
- state = GTK_STATE_SELECTED;
- if (!gtk_widget_get_sensitive (widget))
- state = GTK_STATE_INSENSITIVE;
- style = gtk_widget_get_style (widget);
- text_color = style->text[gtk_widget_get_state (widget)];
- bar_text_color = style->fg[state];
+
+ state = gtk_widget_get_state_flags (widget);
+ context = gtk_widget_get_style_context (widget);
+
+ gtk_style_context_get_color (context, state, &text_color);
+
+ /* Get foreground color for progressbars */
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR);
+ gtk_style_context_get_color (context, state, &bar_text_color);
+ gtk_style_context_restore (context);
get_progress_area (widget,
&progress_x, &progress_y,
/* If the color is the same, or the progress area has a zero
* size, then we only need to draw once. */
- if ((text_color.pixel == bar_text_color.pixel) ||
+ if (gdk_rgba_equal (&text_color, &bar_text_color) ||
((progress_width == 0) || (progress_height == 0)))
{
draw_text_with_color (entry, cr, &text_color);
}
else /* overwrite_mode */
{
- GdkColor cursor_color;
+ GtkStyleContext *context;
+ GdkRGBA cursor_color;
GdkRectangle rect;
gint x, y;
rect.width = PANGO_PIXELS (cursor_rect.width);
rect.height = PANGO_PIXELS (cursor_rect.height);
- _gtk_widget_get_cursor_color (widget, &cursor_color);
- gdk_cairo_set_source_color (cr, &cursor_color);
+ context = gtk_widget_get_style_context (widget);
+
+ _gtk_style_context_get_cursor_color (context, &cursor_color, NULL);
+ gdk_cairo_set_source_rgba (cr, &cursor_color);
gdk_cairo_rectangle (cr, &rect);
cairo_fill (cr);
if (!block_at_line_end)
{
+ GtkStateFlags state;
+ GdkRGBA color;
+
+ state = gtk_widget_get_state_flags (widget);
+ gtk_style_context_get_background_color (context, state, &color);
+
gdk_cairo_rectangle (cr, &rect);
cairo_clip (cr);
cairo_move_to (cr, x, y);
- gdk_cairo_set_source_color (cr, >k_widget_get_style (widget)->base[gtk_widget_get_state (widget)]);
+ gdk_cairo_set_source_rgba (cr, &color);
pango_cairo_show_layout (cr, layout);
}
}
}
-static void
-gtk_entry_queue_draw (GtkEntry *entry)
-{
- if (gtk_widget_is_drawable (GTK_WIDGET (entry)))
- gdk_window_invalidate_rect (gtk_widget_get_window (GTK_WIDGET (entry)),
- NULL, FALSE);
-}
-
void
_gtk_entry_reset_im_context (GtkEntry *entry)
{
GtkAdjustment *adjustment;
PangoContext *context;
PangoFontMetrics *metrics;
+ GtkStyleContext *style_context;
+ GtkStateFlags state;
gint x, layout_x, border_x, border_y;
gint char_width;
/* Approximate width of a char, so user can see what is ahead/behind */
context = gtk_widget_get_pango_context (widget);
- metrics = pango_context_get_metrics (context,
- gtk_widget_get_style (widget)->font_desc,
+ 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_language (context));
char_width = pango_font_metrics_get_approximate_char_width (metrics) / PANGO_SCALE;
GtkIconInfo *info;
GtkIconTheme *icon_theme;
GtkSettings *settings;
- GtkStateType state;
+ GtkStateFlags state;
GtkWidget *widget;
GdkScreen *screen;
gint width, height;
case GTK_IMAGE_PIXBUF:
break;
case GTK_IMAGE_STOCK:
- state = gtk_widget_get_state (widget);
- gtk_widget_set_state (widget, GTK_STATE_NORMAL);
- icon_info->pixbuf = gtk_widget_render_icon (widget,
- icon_info->stock_id,
- GTK_ICON_SIZE_MENU,
- NULL);
+ state = gtk_widget_get_state_flags (widget);
+ gtk_widget_set_state_flags (widget, 0, TRUE);
+ icon_info->pixbuf = gtk_widget_render_icon_pixbuf (widget,
+ icon_info->stock_id,
+ GTK_ICON_SIZE_MENU);
if (!icon_info->pixbuf)
- icon_info->pixbuf = gtk_widget_render_icon (widget,
- GTK_STOCK_MISSING_IMAGE,
- GTK_ICON_SIZE_MENU,
- NULL);
- gtk_widget_set_state (widget, state);
+ icon_info->pixbuf = gtk_widget_render_icon_pixbuf (widget,
+ GTK_STOCK_MISSING_IMAGE,
+ GTK_ICON_SIZE_MENU);
+ gtk_widget_set_state_flags (widget, state, TRUE);
break;
case GTK_IMAGE_ICON_NAME:
{
icon_theme = gtk_icon_theme_get_for_screen (screen);
settings = gtk_settings_get_for_screen (screen);
-
+
gtk_icon_size_lookup_for_settings (settings,
GTK_ICON_SIZE_MENU,
&width, &height);
if (icon_info->pixbuf == NULL)
{
- state = gtk_widget_get_state (widget);
- gtk_widget_set_state (widget, GTK_STATE_NORMAL);
- icon_info->pixbuf = gtk_widget_render_icon (widget,
- GTK_STOCK_MISSING_IMAGE,
- GTK_ICON_SIZE_MENU,
- NULL);
- gtk_widget_set_state (widget, state);
+ state = gtk_widget_get_state_flags (widget);
+ gtk_widget_set_state_flags (widget, 0, TRUE);
+ icon_info->pixbuf = gtk_widget_render_icon_pixbuf (widget,
+ GTK_STOCK_MISSING_IMAGE,
+ GTK_ICON_SIZE_MENU);
+ gtk_widget_set_state_flags (widget, state, TRUE);
}
}
break;
if (icon_info->pixbuf == NULL)
{
- state = gtk_widget_get_state (widget);
- gtk_widget_set_state (widget, GTK_STATE_NORMAL);
- icon_info->pixbuf = gtk_widget_render_icon (widget,
- GTK_STOCK_MISSING_IMAGE,
- GTK_ICON_SIZE_MENU,
- NULL);
- gtk_widget_set_state (widget, state);
+ state = gtk_widget_get_state_flags (widget);
+ gtk_widget_set_state_flags (widget, 0, TRUE);
+ icon_info->pixbuf = gtk_widget_render_icon_pixbuf (widget,
+ GTK_STOCK_MISSING_IMAGE,
+ GTK_ICON_SIZE_MENU);
+ gtk_widget_set_state_flags (widget, state, TRUE);
}
}
break;
/**
* gtk_entry_get_text_area:
* @entry: a #GtkEntry
- * @text_area: Return location for the text area.
+ * @text_area: (out): Return location for the text area.
*
* Gets the area where the entry's text is drawn. This function is
* useful when drawing something to the entry in a draw callback.
/**
* gtk_entry_get_layout_offsets:
* @entry: a #GtkEntry
- * @x: (allow-none): location to store X offset of layout, or %NULL
- * @y: (allow-none): location to store Y offset of layout, or %NULL
+ * @x: (out) (allow-none): location to store X offset of layout, or %NULL
+ * @y: (out) (allow-none): location to store Y offset of layout, or %NULL
*
*
* Obtains the position of the #PangoLayout used to render text
g_object_freeze_notify (G_OBJECT (entry));
- gtk_widget_ensure_style (GTK_WIDGET (entry));
-
/* need to dup before clearing */
new_id = g_strdup (stock_id);
g_object_freeze_notify (G_OBJECT (entry));
- gtk_widget_ensure_style (GTK_WIDGET (entry));
-
/* need to dup before clearing */
new_name = g_strdup (icon_name);
priv = entry->priv;
icon_info = priv->icons[icon_pos];
- return (icon_info != NULL && !icon_info->nonactivatable);
+ return (!icon_info || !icon_info->nonactivatable);
}
/**
* gtk_entry_get_icon_area:
* @entry: A #GtkEntry
* @icon_pos: Icon position
- * @icon_area: Return location for the icon's area
+ * @icon_area: (out): Return location for the icon's area
*
* Gets the area where entry's icon at @icon_pos is drawn.
* This function is useful when drawing something to the
priv = entry->priv;
- if (!(icon_info = priv->icons[icon_pos]))
- icon_info = priv->icons[icon_pos];
+ if ((icon_info = priv->icons[icon_pos]) == NULL)
+ icon_info = construct_icon_info (GTK_WIDGET (entry), icon_pos);
if (icon_info->tooltip)
g_free (icon_info->tooltip);
priv = entry->priv;
- if (!(icon_info = priv->icons[icon_pos]))
- icon_info = priv->icons[icon_pos];
+ if ((icon_info = priv->icons[icon_pos]) == NULL)
+ icon_info = construct_icon_info (GTK_WIDGET (entry), icon_pos);
if (icon_info->tooltip)
g_free (icon_info->tooltip);
{
GtkEntry *entry = GTK_ENTRY (widget);
GtkEntryPrivate *priv = entry->priv;
- GtkStyle *style;
+ GtkStyleContext *style_context;
GtkWidget *source_widget;
GdkDragAction suggested_action;
gint new_position, old_position;
gint sel1, sel2;
+ GtkBorder padding;
- style = gtk_widget_get_style (widget);
- x -= style->xthickness;
- y -= style->ythickness;
+ style_context = gtk_widget_get_style_context (widget);
+ gtk_style_context_get_padding (style_context, 0, &padding);
+ x -= padding.left;
+ y -= padding.top;
old_position = priv->dnd_position;
new_position = gtk_entry_find_position (entry, x + priv->scroll_offset);
gtk_drag_dest_find_target (widget, context, NULL) != GDK_NONE)
{
source_widget = gtk_drag_get_source_widget (context);
- suggested_action = context->suggested_action;
+ suggested_action = gdk_drag_context_get_suggested_action (context);
if (!gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &sel1, &sel2) ||
new_position < sel1 || new_position > sel2)
/* Default to MOVE, unless the user has
* pressed ctrl or alt to affect available actions
*/
- if ((context->actions & GDK_ACTION_MOVE) != 0)
+ if ((gdk_drag_context_get_actions (context) & GDK_ACTION_MOVE) != 0)
suggested_action = GDK_ACTION_MOVE;
}
GtkEntry *entry = GTK_ENTRY (widget);
GtkEntryPrivate *priv = entry->priv;
GtkEditable *editable = GTK_EDITABLE (widget);
- GtkStyle *style;
+ GtkStyleContext *style_context;
+ GtkBorder padding;
gchar *str;
str = (gchar *) gtk_selection_data_get_text (selection_data);
- style = gtk_widget_get_style (widget);
- x -= style->xthickness;
- y -= style->ythickness;
+ style_context = gtk_widget_get_style_context (widget);
+ gtk_style_context_get_padding (style_context, 0, &padding);
+ x -= padding.left;
+ y -= padding.top;
if (str && priv->editable)
{
end_change (entry);
}
- gtk_drag_finish (context, TRUE, context->action == GDK_ACTION_MOVE, time);
+ gtk_drag_finish (context, TRUE, gdk_drag_context_get_selected_action (context) == GDK_ACTION_MOVE, time);
}
else
{
{
GtkTreeIter iter;
GtkTreeModel *model = NULL;
+ GtkTreeModel *child_model;
+ GtkTreeIter child_iter;
GtkTreeSelection *sel;
gboolean retval = TRUE;
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->priv->tree_view));
if (gtk_tree_selection_get_selected (sel, &model, &iter))
{
+ gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (model), &child_iter, &iter);
+ child_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
g_signal_handler_block (widget, completion->priv->changed_id);
g_signal_emit_by_name (completion, "match-selected",
- model, &iter, &entry_set);
+ child_model, &child_iter, &entry_set);
g_signal_handler_unblock (widget, completion->priv->changed_id);
if (!entry_set)
else
remove_capslock_feedback (entry);
}
+
+/*
+ * _gtk_entry_set_is_cell_renderer:
+ * @entry: a #GtkEntry
+ * @is_cell_renderer: new value
+ *
+ * This is a helper function for GtkComboBox. A GtkEntry in a GtkComboBox
+ * is supposed to behave like a GtkCellEditable when placed in a combo box.
+ *
+ * I.e take up its allocation and get GtkEntry->is_cell_renderer = TRUE.
+ *
+ */
+void
+_gtk_entry_set_is_cell_renderer (GtkEntry *entry,
+ gboolean is_cell_renderer)
+{
+ entry->priv->is_cell_renderer = is_cell_renderer;
+}