#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 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);
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;
}
}
-/* 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);
{
GtkEntry *entry = GTK_ENTRY (widget);
GtkEntryPrivate *priv = entry->priv;
- GdkWindow *window;
gint x = 0, y = 0, width, height;
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);
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
- if (gtk_widget_has_focus (widget))
- state |= GTK_STATE_FLAG_FOCUSED;
+ gtk_style_context_save (context);
+ gtk_style_context_set_state (context, state);
if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)))
{
}
}
+ 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);
g_object_unref (cursor);
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);
}
}
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)
{
- GtkStyleContext *context;
GtkStateFlags state;
GdkRGBA color;
- context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_background_color (context, state, &color);
}
}
-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;
{
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);
/**
* 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
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
{
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)
* 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 it's allocation and get GtkEntry->is_cell_renderer = TRUE.
+ * I.e take up its allocation and get GtkEntry->is_cell_renderer = TRUE.
*
*/
void