From 7e722e76e90944c53f152ca3f28653507a1ce9ed Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Sat, 13 Jun 2009 19:22:17 +0000
Subject: Restored the drawing of pictures on the lines.

git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@74 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
---
 ChangeLog               |  8 ++++++++
 src/analysis/line-int.h |  2 ++
 src/analysis/line.c     | 50 ++++++++++++++++++++++++++++++++++++++++++++-----
 src/analysis/line.h     |  1 +
 4 files changed, 56 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e978740..244a66c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 09-06-13  Cyrille Bagard <nocbos@gmail.com>
 
+	* src/analysis/line.c:
+	* src/analysis/line.h:
+	* src/analysis/line-int.h:
+	Restore the drawing of pictures on the lines by using an internal
+	GTK style rather than the main window one.
+
+09-06-13  Cyrille Bagard <nocbos@gmail.com>
+
 	* src/editor.c:
 	Make the GUI offer to change the view of the current analyzed binary.
 
diff --git a/src/analysis/line-int.h b/src/analysis/line-int.h
index 142230e..a70df85 100644
--- a/src/analysis/line-int.h
+++ b/src/analysis/line-int.h
@@ -72,6 +72,8 @@ struct _GRenderingLineClass
 {
     GObjectClass parent;                    /* A laisser en premier        */
 
+    GtkStyle *style;                        /* Style GTK commun aux lignes */
+
     /* Signaux */
 
     void (* rendering_line_flags_changed) (GRenderingLine *);
diff --git a/src/analysis/line.c b/src/analysis/line.c
index b1af518..2697f77 100644
--- a/src/analysis/line.c
+++ b/src/analysis/line.c
@@ -48,6 +48,8 @@ static void g_rendering_line_class_init(GRenderingLineClass *);
 /* Initialise une instance de ligne de représentation. */
 static void g_rendering_line_init(GRenderingLine *);
 
+/* Charge une image destinée à être rendue avec la ligne. */
+static GdkPixbuf *g_rendering_line_render_icon(const GRenderingLine *, const char *, GtkIconSize);
 
 
 /* Indique le type définit pour une ligne de représentation. */
@@ -69,6 +71,8 @@ G_DEFINE_TYPE(GRenderingLine, g_rendering_line, G_TYPE_OBJECT);
 
 static void g_rendering_line_class_init(GRenderingLineClass *klass)
 {
+    klass->style = gtk_style_new();
+
     g_signal_new("rendering-line-flags-changed",
                  G_TYPE_RENDERING_LINE,
                  G_SIGNAL_RUN_LAST,
@@ -224,6 +228,43 @@ RenderingLineFlag g_rendering_line_get_flags(const GRenderingLine *line)
 
 /******************************************************************************
 *                                                                             *
+*  Paramètres  : line     = ligne dont les informations sont à consulter.     *
+*                stock_id = identifiant GTK de l'image à charger.             *
+*                size     = taille de l'image souhaitée.                      *
+*                                                                             *
+*  Description : Charge une image destinée à être rendue avec la ligne.       *
+*                                                                             *
+*  Retour      : Image prête à emploi ou NULL.                                *
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+static GdkPixbuf *g_rendering_line_render_icon(const GRenderingLine *line, const char *stock_id, GtkIconSize size)
+{
+    GdkPixbuf *result;                      /* Elément mis en place / NULL */
+    GtkStyle *style;                        /* Style GTK à utiliser        */
+    GtkIconSet *icon_set;                   /* Liste d'icones              */
+
+    style = G_RENDERING_LINE_GET_CLASS(line)->style;
+
+    icon_set = gtk_style_lookup_icon_set(style, stock_id);
+
+    if (icon_set == NULL)
+        return NULL;
+
+    result = gtk_icon_set_render_icon(icon_set, style,
+                                      gtk_widget_get_default_direction(),
+                                      GTK_STATE_NORMAL, size,
+                                      NULL, NULL);
+
+    return result;
+
+}
+
+
+/******************************************************************************
+*                                                                             *
 *  Paramètres  : line     = adresse de la structure à représenter.            *
 *                drawable = support de rendu pour le dessin.                  *
 *                gc       = contexte graphique à utiliser.                    *
@@ -246,12 +287,11 @@ void g_rendering_line_draw(GRenderingLine *line, GdkDrawable *drawable, GdkGC *g
 
     gdk_draw_layout(drawable, gc, x1, y, line->layout);
 
-#if 0
     if (line->flags & RLF_BREAK_POINT)
-        pixbuf = gtk_widget_render_icon(mywid, "gtk-yes", GTK_ICON_SIZE_MENU, NULL);
+        pixbuf = g_rendering_line_render_icon(line, "gtk-yes", GTK_ICON_SIZE_MENU);
 
     else if (line->flags & RLF_RUNNING_BP)
-        pixbuf = gtk_widget_render_icon(mywid, "gtk-no", GTK_ICON_SIZE_MENU, NULL);
+        pixbuf = g_rendering_line_render_icon(line, "gtk-no", GTK_ICON_SIZE_MENU);
 
     else pixbuf = NULL;
 
@@ -268,7 +308,7 @@ void g_rendering_line_draw(GRenderingLine *line, GdkDrawable *drawable, GdkGC *g
     /* Le point d'entrée prime */
 
     if (line->flags & RLF_ENTRY_POINT)
-        pixbuf = gtk_widget_render_icon(mywid, "gtk-go-forward", GTK_ICON_SIZE_MENU, NULL);
+        pixbuf = g_rendering_line_render_icon(line, "gtk-go-forward", GTK_ICON_SIZE_MENU);
 
     else pixbuf = NULL;
 
@@ -281,7 +321,7 @@ void g_rendering_line_draw(GRenderingLine *line, GdkDrawable *drawable, GdkGC *g
         g_object_unref(pixbuf);
 
     }
-#endif
+
 }
 
 
diff --git a/src/analysis/line.h b/src/analysis/line.h
index 5744d24..ae7698e 100644
--- a/src/analysis/line.h
+++ b/src/analysis/line.h
@@ -70,6 +70,7 @@ typedef struct _disass_options
 #define G_RENDERING_LINE(obj)               (G_TYPE_CHECK_INSTANCE_CAST((obj), g_rendering_line_get_type(), GRenderingLine))
 #define G_IS_RENDERING_LINE(obj)            (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_rendering_line_get_type()))
 #define G_RENDERING_LINE_GET_IFACE(inst)    (G_TYPE_INSTANCE_GET_INTERFACE((inst), g_rendering_line_get_type(), GRenderingLineIface))
+#define G_RENDERING_LINE_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_RENDERING_LINE, GRenderingLineClass))
 
 
 /* Ligne de représentation générique (instance) */
-- 
cgit v0.11.2-87-g4458