[gimp/gtk3-port: 81/249] app: port the tag entry to GTK+ 3.0
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 81/249] app: port the tag entry to GTK+ 3.0
- Date: Mon, 21 Mar 2011 20:42:47 +0000 (UTC)
commit 104187b6ba660ea32f7af7b409f38f78c5831032
Author: Michael Natterer <mitch gimp org>
Date: Tue Oct 19 20:05:17 2010 +0200
app: port the tag entry to GTK+ 3.0
app/widgets/gimptagentry.c | 52 ++++++++++++++++++++-----------------------
1 files changed, 24 insertions(+), 28 deletions(-)
---
diff --git a/app/widgets/gimptagentry.c b/app/widgets/gimptagentry.c
index 31f5143..0f043ab 100644
--- a/app/widgets/gimptagentry.c
+++ b/app/widgets/gimptagentry.c
@@ -110,8 +110,8 @@ static gboolean gimp_tag_entry_auto_complete (GimpTagEntry *entr
static void gimp_tag_entry_toggle_desc (GimpTagEntry *widget,
gboolean show);
-static gboolean gimp_tag_entry_expose (GtkWidget *widget,
- GdkEventExpose *event);
+static gboolean gimp_tag_entry_draw (GtkWidget *widget,
+ cairo_t *cr);
static void gimp_tag_entry_commit_region (GString *tags,
GString *mask);
static void gimp_tag_entry_commit_tags (GimpTagEntry *entry);
@@ -207,8 +207,8 @@ gimp_tag_entry_init (GimpTagEntry *entry)
g_signal_connect (entry, "focus-out-event",
G_CALLBACK (gimp_tag_entry_focus_out),
NULL);
- g_signal_connect_after (entry, "expose-event",
- G_CALLBACK (gimp_tag_entry_expose),
+ g_signal_connect_after (entry, "draw",
+ G_CALLBACK (gimp_tag_entry_draw),
NULL);
}
@@ -1253,10 +1253,11 @@ gimp_tag_entry_toggle_desc (GimpTagEntry *tag_entry,
}
static gboolean
-gimp_tag_entry_expose (GtkWidget *widget,
- GdkEventExpose *event)
+gimp_tag_entry_draw (GtkWidget *widget,
+ cairo_t *cr)
{
GimpTagEntry *tag_entry = GIMP_TAG_ENTRY (widget);
+ GdkWindow *window;
PangoLayout *layout;
PangoAttrList *attr_list;
PangoAttribute *attribute;
@@ -1267,8 +1268,9 @@ gimp_tag_entry_expose (GtkWidget *widget,
gint offset;
const char *display_text;
- /* eeeeeek */
- if (event->window != gtk_entry_get_text_window (GTK_ENTRY (widget)))
+ window = gtk_entry_get_text_window (GTK_ENTRY (widget));
+
+ if (! gtk_cairo_should_draw_window (cr, window))
return FALSE;
if (! GIMP_TAG_ENTRY (widget)->description_shown)
@@ -1292,22 +1294,16 @@ gimp_tag_entry_expose (GtkWidget *widget,
pango_layout_set_attributes (layout, attr_list);
pango_attr_list_unref (attr_list);
-#if GTK_CHECK_VERSION (2, 24, 0)
- window_width = gdk_window_get_width (event->window);
- window_height = gdk_window_get_height (event->window);
-#else
- gdk_drawable_get_size (GDK_DRAWABLE (event->window),
- &window_width, &window_height);
-#endif
+ window_width = gdk_window_get_width (window);
+ window_height = gdk_window_get_height (window);
pango_layout_get_size (layout,
&layout_width, &layout_height);
offset = (window_height - PANGO_PIXELS (layout_height)) / 2;
gtk_paint_layout (gtk_widget_get_style (widget),
- event->window,
+ cr,
GTK_STATE_INSENSITIVE,
TRUE,
- &event->area,
widget,
NULL,
(gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ?
@@ -1337,9 +1333,9 @@ gimp_tag_entry_key_press (GtkWidget *widget,
switch (event->keyval)
{
- case GDK_Tab:
- case GDK_KP_Tab:
- case GDK_ISO_Left_Tab:
+ case GDK_KEY_Tab:
+ case GDK_KEY_KP_Tab:
+ case GDK_KEY_ISO_Left_Tab:
/* allow to leave the widget with Ctrl+Tab */
if (! (event->state & GDK_CONTROL_MASK))
{
@@ -1356,21 +1352,21 @@ gimp_tag_entry_key_press (GtkWidget *widget,
}
return TRUE;
- case GDK_Return:
+ case GDK_KEY_Return:
gimp_tag_entry_commit_tags (entry);
break;
- case GDK_Left:
+ case GDK_KEY_Left:
gimp_tag_entry_previous_tag (entry,
(event->state & GDK_SHIFT_MASK) ? TRUE : FALSE);
return TRUE;
- case GDK_Right:
+ case GDK_KEY_Right:
gimp_tag_entry_next_tag (entry,
(event->state & GDK_SHIFT_MASK) ? TRUE : FALSE);
return TRUE;
- case GDK_BackSpace:
+ case GDK_KEY_BackSpace:
{
gint selection_start;
gint selection_end;
@@ -1393,7 +1389,7 @@ gimp_tag_entry_key_press (GtkWidget *widget,
}
break;
- case GDK_Delete:
+ case GDK_KEY_Delete:
{
gint selection_start;
gint selection_end;
@@ -1416,8 +1412,8 @@ gimp_tag_entry_key_press (GtkWidget *widget,
}
break;
- case GDK_Up:
- case GDK_Down:
+ case GDK_KEY_Up:
+ case GDK_KEY_Down:
if (entry->recent_list != NULL)
{
gchar *recent_item;
@@ -1427,7 +1423,7 @@ gimp_tag_entry_key_press (GtkWidget *widget,
gimp_tag_entry_add_to_recent (entry, very_recent_item, TRUE);
g_free (very_recent_item);
- if (event->keyval == GDK_Up)
+ if (event->keyval == GDK_KEY_Up)
{
recent_item = (gchar *) g_list_first (entry->recent_list)->data;
entry->recent_list = g_list_remove (entry->recent_list, recent_item);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]