diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2014-01-26 23:00:18 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2014-01-26 23:00:18 (GMT) |
commit | 84790a5b420d0a9ce658013573b180ce059db325 (patch) | |
tree | 5000d25a0d5ede63e671364e1e017fbb6674b5f5 /src/gtkext/gtkbinarystrip.c | |
parent | abb191e42e356914bd09176a6d6c5bf89ec50bbf (diff) |
Saved the first steps of the migration to GTK+ v3.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@367 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/gtkext/gtkbinarystrip.c')
-rw-r--r-- | src/gtkext/gtkbinarystrip.c | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/src/gtkext/gtkbinarystrip.c b/src/gtkext/gtkbinarystrip.c index 3f4a6a6..3b36c8b 100644 --- a/src/gtkext/gtkbinarystrip.c +++ b/src/gtkext/gtkbinarystrip.c @@ -71,7 +71,7 @@ static void gtk_binary_strip_size_allocate(GtkWidget *, GtkAllocation *); static gboolean gtk_binary_strip_button_release(GtkWidget *, GdkEventButton *); /* Met à jour l'affichage du composant d'affichage. */ -static gboolean gtk_binary_strip_expose(GtkWidget *, GdkEventExpose *); +static gboolean gtk_binary_strip_draw(GtkWidget *, cairo_t *); /* Prépare l'affichage d'une astuce. */ static gboolean gtk_binary_strip_query_tooltip(GtkWidget *, gint, gint, gboolean, GtkTooltip *); @@ -103,7 +103,7 @@ static void gtk_binary_strip_class_init(GtkBinaryStripClass *class) widget_class->realize = gtk_binary_strip_realize; widget_class->size_allocate = gtk_binary_strip_size_allocate; widget_class->button_release_event = gtk_binary_strip_button_release; - widget_class->expose_event = gtk_binary_strip_expose; + widget_class->draw = gtk_binary_strip_draw; widget_class->query_tooltip = gtk_binary_strip_query_tooltip; g_signal_new("select-address", @@ -186,8 +186,8 @@ static void gtk_binary_strip_realize(GtkWidget *widget) GTK_WIDGET_CLASS(gtk_binary_strip_parent_class)->realize(widget); cursor = gdk_cursor_new(GDK_HAND1); - gdk_window_set_cursor(widget->window, cursor); - gdk_cursor_unref(cursor); + gdk_window_set_cursor(gtk_widget_get_window(widget), cursor); + g_object_unref(cursor); gtk_widget_add_events(widget, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); @@ -250,6 +250,8 @@ static void gtk_binary_strip_size_allocate(GtkWidget *widget, GtkAllocation *all static gboolean gtk_binary_strip_button_release(GtkWidget *widget, GdkEventButton *event) { + gint width; /* Laugeur du composant */ + gint height; /* Hauteur du composant */ GtkBinaryStrip *strip; /* Autre version du composant */ GExeFormat *format; /* Format du binaire */ GBinPortion *portions; /* Portions binaires à dessiner*/ @@ -258,7 +260,11 @@ static gboolean gtk_binary_strip_button_release(GtkWidget *widget, GdkEventButto if (event->x < 0 || event->y < 0) return FALSE; - if (event->x >= widget->allocation.width || event->y >= widget->allocation.height) + + width = gtk_widget_get_allocated_width(widget); + height = gtk_widget_get_allocated_height(widget); + + if (event->x >= width || event->y >= height) return FALSE; strip = GTK_BINARY_STRIP(widget); @@ -267,8 +273,8 @@ static gboolean gtk_binary_strip_button_release(GtkWidget *widget, GdkEventButto area.x = 0; area.y = 0; - area.width = widget->allocation.width; - area.height = widget->allocation.height; + area.width = width; + area.height = height; if (g_binary_portion_get_addr_from_pos(portions, event->x, &area, &addr)) { @@ -289,7 +295,7 @@ static gboolean gtk_binary_strip_button_release(GtkWidget *widget, GdkEventButto /****************************************************************************** * * * Paramètres : widget = composant GTK à redessiner. * -* event = informations liées à l'événement. * +* cr = contexte graphique associé à l'événement. * * * * Description : Met à jour l'affichage du composant d'affichage. * * * @@ -299,13 +305,13 @@ static gboolean gtk_binary_strip_button_release(GtkWidget *widget, GdkEventButto * * ******************************************************************************/ -static gboolean gtk_binary_strip_expose(GtkWidget *widget, GdkEventExpose *event) +static gboolean gtk_binary_strip_draw(GtkWidget *widget, cairo_t *cr) { GtkBinaryStrip *strip; /* Autre vision du composant */ - cairo_t *cr; /* Contexte graphique */ GExeFormat *format; /* Format du binaire */ GBinPortion *portions; /* Portions binaires à dessiner*/ GdkRectangle full; /* Taille totale de la surface */ + GdkRGBA *color; /* Couleur du curseur */ strip = GTK_BINARY_STRIP(widget); @@ -315,19 +321,12 @@ static gboolean gtk_binary_strip_expose(GtkWidget *widget, GdkEventExpose *event format = g_loaded_binary_get_format(strip->binary); portions = g_exe_format_get_portions(format); - cr = gdk_cairo_create(widget->window); - - cairo_rectangle(cr, - event->area.x, event->area.y, - event->area.width, event->area.height); - cairo_clip(cr); - /* Dessin des portions de binaire */ full.x = 0; full.y = 1; - full.width = widget->allocation.width; - full.height = widget->allocation.height - 1; + full.width = gtk_widget_get_allocated_width(widget); + full.height = gtk_widget_get_allocated_height(widget) - 1; g_binary_portion_draw(portions, cr, &full); @@ -337,10 +336,12 @@ static gboolean gtk_binary_strip_expose(GtkWidget *widget, GdkEventExpose *event { cairo_set_line_width(cr, 1); - cairo_set_source_rgb(cr, - (1.0 * widget->style->bg[GTK_STATE_NORMAL].red) / USHRT_MAX, - (1.0 * widget->style->bg[GTK_STATE_NORMAL].green) / USHRT_MAX, - (1.0 * widget->style->bg[GTK_STATE_NORMAL].blue )/ USHRT_MAX); + gtk_style_context_get(gtk_widget_get_style_context(widget), GTK_STATE_FLAG_NORMAL, + GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &color, NULL); + + cairo_set_source_rgb(cr, color->red, color->green, color->blue); + + gdk_rgba_free(color); cairo_move_to(cr, strip->cursor_pos, STRIP_MARKER_SIZE); cairo_line_to(cr, strip->cursor_pos + STRIP_MARKER_SIZE, 0); @@ -356,10 +357,6 @@ static gboolean gtk_binary_strip_expose(GtkWidget *widget, GdkEventExpose *event } - /* Clôture */ - - cairo_destroy (cr); - return FALSE; } @@ -400,8 +397,8 @@ static gboolean gtk_binary_strip_query_tooltip(GtkWidget *widget, gint x, gint y area.x = 0; area.y = 0; - area.width = widget->allocation.width; - area.height = widget->allocation.height; + area.width = gtk_widget_get_allocated_width(widget); + area.height = gtk_widget_get_allocated_height(widget); result = g_binary_portion_query_tooltip(portions, x, y, &area, tooltip); |