diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2009-04-05 01:17:39 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2009-04-05 01:17:39 (GMT) |
commit | 193565c98b3c8df5c18f6f305871d60e2dd88e3b (patch) | |
tree | ff78567a274a5de1340c19b18bb690d27fd87d85 /src/gtksnippet.c | |
parent | 4ad9e532a78401f787f0a8a6742095512b520488 (diff) |
Managed double linked lists in a more powerful way.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@56 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/gtksnippet.c')
-rw-r--r-- | src/gtksnippet.c | 70 |
1 files changed, 13 insertions, 57 deletions
diff --git a/src/gtksnippet.c b/src/gtksnippet.c index bd5b3df..f56ccd0 100644 --- a/src/gtksnippet.c +++ b/src/gtksnippet.c @@ -143,7 +143,7 @@ static void gtk_snippet_size_allocate(GtkWidget *widget, static void gtk_snippet_realize(GtkWidget *widget); -static gboolean gtk_snippet_button_press(GtkSnippet *snippet, GdkEventButton *event, gpointer *data); +static gboolean gtk_snippet_button_press(GtkWidget *widget, GdkEventButton *event); static gboolean gtk_snippet_expose(GtkWidget *widget, GdkEventExpose *event); @@ -175,15 +175,8 @@ gtk_snippet_get_type(void) return gtk_snippet_type; } -void -gtk_snippet_set_state(GtkSnippet *cpu, gint num) -{ - cpu->sel = num; - gtk_snippet_paint(GTK_WIDGET(cpu)); -} - -GtkWidget * gtk_snippet_new() +GtkWidget *gtk_snippet_new(void) { GtkSnippet *result; @@ -300,13 +293,16 @@ gtk_snippet_realize(GtkWidget *widget) } -static gboolean gtk_snippet_button_press(GtkSnippet *snippet, GdkEventButton *event, gpointer *data) +static gboolean gtk_snippet_button_press(GtkWidget *widget, GdkEventButton *event) { + GtkSnippet *snippet; /* COmposant GTK réel */ unsigned int index; /* Indice de la ligne visée */ PangoLayoutIter *iter; /* Boucle de parcours */ int y0; /* Ordonnée du haut d'une ligne*/ int y1; /* Ordonnée du bas d'une ligne */ + snippet = GTK_SNIPPET(widget); + index = 0; iter = pango_layout_get_iter(snippet->layout); @@ -342,7 +338,7 @@ gtk_snippet_expose(GtkWidget *widget, g_return_val_if_fail(GTK_IS_SNIPPET(widget), FALSE); g_return_val_if_fail(event != NULL, FALSE); - gtk_snippet_paint(widget); + gtk_snippet_paint(GTK_SNIPPET(widget)); return FALSE; } @@ -410,7 +406,7 @@ gtk_snippet_paint(GtkSnippet *snippet) y0 = 0; - dl_list_for_each(/**/liter, snippet->lines, rendering_line *) + for (/* l! */liter = snippet->lines; liter != NULL; liter = g_rendering_line_get_next_iter(snippet->lines, liter)) { draw_rendering_line(liter, GDK_DRAWABLE(widget->window), snippet->gc, MARGIN_SPACE, 2 * MARGIN_SPACE + snippet->line_height, @@ -421,7 +417,6 @@ gtk_snippet_paint(GtkSnippet *snippet) } - } @@ -446,27 +441,6 @@ gtk_snippet_destroy(GtkObject *object) -void gtk_snippet_set_sel(GtkSnippet *cpu, gint sel) -{ - cpu->sel = sel; - -} - - - -void gtk_snippet_test(GtkSnippet *snippet) -{ - - - - pango_layout_set_markup(snippet->layout, "<tt>int\t<span foreground='#ff0000'>80</span></tt>", -1); - - - - -} - - /****************************************************************************** @@ -571,18 +545,9 @@ void gtk_snippet_set_processor(GtkSnippet *snippet, const asm_processor *proc) void gtk_snippet_set_rendering_lines(GtkSnippet *snippet, rendering_line *lines) { - rendering_line *iter; /* Boucle de parcours */ - off_t bin_len; /* Taille d'instruction */ - snippet->lines = lines; - bin_len = 0; - - dl_list_for_each(iter, lines, rendering_line *) - get_rendering_line_binary_len(iter, &bin_len); - - dl_list_for_each(iter, lines, rendering_line *) - set_rendering_line_max_binary_len(iter, bin_len); + g_rendering_lines_update_bin_len(lines); gtk_snippet_recompute_size_request(snippet); @@ -608,21 +573,12 @@ void gtk_snippet_recompute_size_request(GtkSnippet *snippet) { int width; /* Largeur de l'objet actuelle */ int height; /* Hauteur de l'objet actuelle */ - rendering_line *iter; /* Boucle de parcours */ - width = 0; - height = 0; - - dl_list_for_each(iter, snippet->lines, rendering_line *) - { - get_rendering_line_size(iter, &width, &height); - - if (iter == snippet->lines) - snippet->line_height = height; - - } + g_rendering_lines_get_size(snippet->lines, &width, &height, &snippet->line_height); - gtk_widget_set_size_request(GTK_WIDGET(snippet), width + 2 * MARGIN_SPACE + snippet->line_height, height); + gtk_widget_set_size_request(GTK_WIDGET(snippet), + width + 2 * MARGIN_SPACE + snippet->line_height, + height); } |