summaryrefslogtreecommitdiff
path: root/src/gtkext
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2009-08-30 10:55:45 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2009-08-30 10:55:45 (GMT)
commitac447bc36e65b91f97434cf2613ccb1e768267e0 (patch)
tree471f3b49629269d7ea44a6ea8b9177fe7e437817 /src/gtkext
parent184249f07fb32fb2449723f5f94ce221015231b7 (diff)
Rendered using the GTK buffer (crappy version).
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@107 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/gtkext')
-rw-r--r--src/gtkext/gtkblockview.c177
-rw-r--r--src/gtkext/gtkextstatusbar.c12
2 files changed, 184 insertions, 5 deletions
diff --git a/src/gtkext/gtkblockview.c b/src/gtkext/gtkblockview.c
index 2659b0d..99825f0 100644
--- a/src/gtkext/gtkblockview.c
+++ b/src/gtkext/gtkblockview.c
@@ -27,8 +27,12 @@
#include <malloc.h>
#include <string.h>
+#define GTK_TEXT_USE_INTERNAL_UNSUPPORTED_API
+#include <gtk/gtktextdisplay.h>
+
#include "gtkbinview-int.h"
+#include "../analysis/exporter.h"
#include "../common/dllist.h"
@@ -46,6 +50,9 @@ struct _GtkBlockView
bool show_vaddress; /* Affichage des adresses ? */
bool show_code; /* Affichage du code brut ? */
+ GtkTextBuffer *buffer; /* Code sous forme de texte */
+ GtkTextLayout *_layout; /* Disposition du texte */
+
PangoLayout *layout; /* Moteur de rendu du code ASM */
int line_height; /* Hauteur maximale des lignes */
@@ -61,6 +68,26 @@ struct _GtkBlockViewClass
+
+static void
+gtk_text_view2_set_attributes_from_style (GtkTextAttributes *values,
+ GtkStyle *style)
+{
+ PangoFontDescription *font_desc;
+
+ values->appearance.bg_color = style->base[GTK_STATE_NORMAL];
+ values->appearance.fg_color = style->text[GTK_STATE_NORMAL];
+
+ if (values->font)
+ pango_font_description_free (values->font);
+
+ font_desc = pango_font_description_from_string ("mono 10");
+
+ values->font = pango_font_description_copy (/*style->*/font_desc);
+ pango_font_description_free (font_desc);
+}
+
+
/* Procède à l'initialisation de l'afficheur d'un bloc binaire. */
static void gtk_block_view_init(GtkBlockView *);
@@ -110,7 +137,7 @@ static void gtk_block_view_size_allocate(GtkWidget *widget,
static gboolean gtk_block_view_button_press(GtkWidget *, GdkEventButton *event);
/* Met à jour l'affichage de la vue sous forme de bloc. */
-static gboolean gtk_block_view_expose(GtkWidget *widget, GdkEventExpose *event);
+static gboolean gtk_block_view_expose(GtkWidget *, GdkEventExpose *);
static void gtk_block_view_destroy(GtkObject *object);
@@ -182,11 +209,100 @@ static void gtk_block_view_init(GtkBlockView *view)
{
GtkBinView *binview; /* Instance parente */
+
+ PangoTabArray *tabs;
+ gint current_y;
+ PangoFontDescription *font_desc;
+ GList *child_exposes;
+ PangoContext *ltr_context, *rtl_context;
+ GtkTextAttributes *style;
+ static bool done = false;
+
+
binview = GTK_BIN_VIEW(view);
binview->set_lines = (set_rendering_lines_fc)gtk_block_view_set_rendering_lines;
binview->get_coordinates = (get_addr_coordinates_fc)gtk_block_view_get_address_coordinates;
+
+
+ view->buffer = gtk_text_buffer_new(get_gtk_tag_table());
+
+
+
+ view->_layout = gtk_text_layout_new();
+ gtk_text_layout_set_buffer(view->_layout, view->buffer);
+
+
+
+ if (!done || 1)
+ {
+ done = true;
+
+ gtk_text_layout_set_cursor_visible(GTK_BLOCK_VIEW(view)->_layout, FALSE);
+
+ gtk_text_layout_set_overwrite_mode(GTK_BLOCK_VIEW(view)->_layout, FALSE);
+
+
+ ltr_context = gtk_widget_create_pango_context(view);
+ pango_context_set_base_dir(ltr_context, PANGO_DIRECTION_LTR);
+ rtl_context = gtk_widget_create_pango_context(view);
+ pango_context_set_base_dir(rtl_context, PANGO_DIRECTION_RTL);
+
+ gtk_text_layout_set_contexts(GTK_BLOCK_VIEW(view)->_layout, ltr_context, rtl_context);
+
+
+
+ tabs = pango_tab_array_new_with_positions(5, TRUE,
+ PANGO_TAB_LEFT, 120,
+ PANGO_TAB_LEFT, 290,
+ PANGO_TAB_LEFT, 50,
+ PANGO_TAB_LEFT, 50,
+ PANGO_TAB_LEFT, 50);
+
+
+ style = gtk_text_attributes_new ();
+
+ gtk_widget_ensure_style(view);
+
+ font_desc = pango_font_description_from_string ("mono 10");
+ gtk_widget_modify_font (view, font_desc);
+ pango_font_description_free (font_desc);
+
+ gtk_text_view2_set_attributes_from_style(style, GTK_WIDGET(view)->style);
+ /*
+ style->pixels_above_lines = 5;
+ style->pixels_below_lines = 5;
+ style->pixels_inside_wrap = 10;
+ style->left_margin = 10;
+ style->right_margin = 10;
+ style->indent = 10;*/
+ style->left_margin = 10;
+ style->right_margin = 10;
+ style->tabs = tabs;
+
+ style->wrap_mode = GTK_WRAP_WORD;
+ style->justification = GTK_JUSTIFY_LEFT;
+
+ style->direction = gtk_widget_get_direction(view);
+
+
+ gtk_text_layout_set_default_style(GTK_BLOCK_VIEW(view)->_layout, style);
+
+ gtk_text_attributes_unref(style);
+
+
+ //gtk_text_layout_get_size (GTK_BLOCK_VIEW(view)->_layout, &width, &height);
+
+ gtk_text_layout_set_screen_width (GTK_BLOCK_VIEW(view)->_layout,
+ MAX (1, 1000));
+
+ }
+
+
+ gtk_text_buffer_set_text(view->buffer, "\t|\t|\t|\t|\t|\n", -1);
+
+
}
@@ -240,6 +356,7 @@ gtk_block_view_size_allocate(GtkWidget *widget,
static void gtk_block_view_realize(GtkWidget *widget)
{
GtkBinViewClass *parent_class; /* Version pure du parent */
+ PangoFontDescription *font_desc;
parent_class = GTK_BIN_VIEW_CLASS(g_type_class_peek_parent(GTK_BLOCK_VIEW_GET_CLASS(widget)));
@@ -247,6 +364,10 @@ static void gtk_block_view_realize(GtkWidget *widget)
GTK_BLOCK_VIEW(widget)->layout = gtk_widget_create_pango_layout(widget, NULL);
+ font_desc = pango_font_description_from_string("mono 10");
+ gtk_widget_modify_font(widget, font_desc);
+ pango_font_description_free(font_desc);
+
}
@@ -334,8 +455,12 @@ static gboolean gtk_block_view_expose(GtkWidget *widget, GdkEventExpose *event)
int y; /* Ordonnée du haut d'une ligne*/
GRenderingLine *iter; /* Boucle de parcours */
- view = GTK_BIN_VIEW(widget);
+ PangoFontDescription *font_desc;
+ GList *child_exposes;
+
+ view = GTK_BIN_VIEW(widget);
+#if 0
gdk_window_begin_paint_region(GDK_DRAWABLE(widget->window), event->region);
gdk_gc_set_clip_region(view->gc, event->region);
@@ -351,7 +476,7 @@ static gboolean gtk_block_view_expose(GtkWidget *widget, GdkEventExpose *event)
TRUE, 0, 0, width, height);
gdk_gc_set_foreground(view->gc, &values.foreground);
-
+ /*
y = event->area.y;
iter = g_rendering_line_find_by_y(view->lines, view->last, &y);
@@ -367,8 +492,21 @@ static gboolean gtk_block_view_expose(GtkWidget *widget, GdkEventExpose *event)
y += GTK_BLOCK_VIEW(view)->line_height;
}
-
+ */
gdk_window_end_paint(GDK_DRAWABLE(widget->window));
+#endif
+
+ gtk_text_layout_set_screen_width (GTK_BLOCK_VIEW(view)->_layout,
+ MAX (1, 1000));
+
+ //gtk_text_buffer_set_text(GTK_BLOCK_VIEW(view)->buffer, "Hello, this some text\n", -1);
+
+ font_desc = pango_font_description_from_string ("mono 10");
+ gtk_widget_modify_font (view, font_desc);
+ pango_font_description_free (font_desc);
+
+ gtk_text_layout_draw(GTK_BLOCK_VIEW(view)->_layout, widget, GDK_DRAWABLE(widget->window),
+ NULL, 0, 0, 0, 0, 5000, 50000, &child_exposes);
return TRUE;
@@ -482,6 +620,7 @@ void gtk_block_view_set_format(GtkBlockView *view, const exe_format *format)
static void gtk_block_view_set_rendering_lines(GtkBlockView *view, GRenderingLine *lines, GRenderingLine *last)
{
GRenderingLine *iter; /* Boucle de parcours */
+ GtkTextIter pos; /* Point d'insertion */
for (iter = GTK_BIN_VIEW(view)->lines;
iter != NULL;
@@ -494,6 +633,24 @@ static void gtk_block_view_set_rendering_lines(GtkBlockView *view, GRenderingLin
g_rendering_line_update_bin_len(GTK_BIN_VIEW(view)->lines,
GTK_BIN_VIEW(view)->last, view->rendering);
+ for (iter = GTK_BIN_VIEW(view)->lines;
+ iter != NULL;
+ iter = g_rendering_line_get_next_iter(GTK_BIN_VIEW(view)->lines, iter, GTK_BIN_VIEW(view)->last))
+ {
+ if (iter != GTK_BIN_VIEW(view)->lines)
+ {
+ gtk_text_buffer_get_end_iter(view->buffer, &pos);
+ gtk_text_buffer_insert_with_tags(view->buffer, &pos, "\n", 1, NULL);
+ }
+
+ gtk_text_buffer_get_end_iter(view->buffer, &pos);
+ g_content_exporter_add_to_gtk_buffer(G_CONTENT_EXPORTER(iter), view->rendering,
+ view->buffer, &pos);
+
+ }
+
+ gtk_text_layout_validate(GTK_BLOCK_VIEW(view)->_layout, 100000);
+
gtk_block_view_recompute_size_request(view);
}
@@ -519,6 +676,16 @@ void gtk_block_view_recompute_size_request(GtkBlockView *view)
int width; /* Largeur de l'objet actuelle */
int height; /* Hauteur de l'objet actuelle */
+ gtk_text_layout_get_size(view->_layout, &width, &height);
+
+ gtk_widget_set_size_request(GTK_WIDGET(view),
+ width + 2 * MARGIN_SPACE + 20/*view->line_height*/,
+ height);
+
+
+ printf("req size :: (%d ; %d)\n", width, height);
+
+ /*
g_rendering_line_get_size(GTK_BIN_VIEW(view)->lines,
GTK_BIN_VIEW(view)->last,
view->rendering,
@@ -527,7 +694,7 @@ void gtk_block_view_recompute_size_request(GtkBlockView *view)
gtk_widget_set_size_request(GTK_WIDGET(view),
width + 2 * MARGIN_SPACE + view->line_height,
height);
-
+ */
}
diff --git a/src/gtkext/gtkextstatusbar.c b/src/gtkext/gtkextstatusbar.c
index cb6851d..79beda2 100644
--- a/src/gtkext/gtkextstatusbar.c
+++ b/src/gtkext/gtkextstatusbar.c
@@ -124,6 +124,8 @@ guint gtk_extended_status_bar_push(GtkExtStatusBar *bar, const gchar *message, g
{
guint result; /* Identifiant à retourner */
+ gdk_threads_enter();
+
result = gtk_statusbar_push(GTK_STATUSBAR(bar), bar->context, message);
bar->msg_count++;
@@ -143,6 +145,10 @@ guint gtk_extended_status_bar_push(GtkExtStatusBar *bar, const gchar *message, g
}
else gtk_widget_hide(GTK_WIDGET(bar->progress));
+ gdk_flush ();
+
+ gdk_threads_leave();
+
return result;
}
@@ -203,6 +209,8 @@ void gtk_extended_status_bar_remove(GtkExtStatusBar *bar, guint id)
{
size_t i; /* Boucle de parcours */
+ gdk_threads_enter();
+
gtk_statusbar_remove(GTK_STATUSBAR(bar), bar->context, id);
for (i = 0; i < bar->msg_count; i++)
@@ -225,4 +233,8 @@ void gtk_extended_status_bar_remove(GtkExtStatusBar *bar, guint id)
else
gtk_widget_hide(GTK_WIDGET(bar->progress));
+ gdk_flush ();
+
+ gdk_threads_leave();
+
}