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 | |
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')
37 files changed, 578 insertions, 448 deletions
diff --git a/src/arch/archbase.h b/src/arch/archbase.h index 5ef412c..407d66c 100644 --- a/src/arch/archbase.h +++ b/src/arch/archbase.h @@ -30,8 +30,8 @@ -#define OFF_FMT "%ld" -#define OFF_CAST(v) ((long)v) +#define OFF_FMT "%llu" +#define OFF_CAST(v) ((unsigned long long)v) /* Octet de données binaires */ diff --git a/src/dialogs/Makefile.am b/src/dialogs/Makefile.am index 70642b2..05bd50e 100644 --- a/src/dialogs/Makefile.am +++ b/src/dialogs/Makefile.am @@ -3,11 +3,11 @@ noinst_LTLIBRARIES = libdialogs.la libdialogs_la_SOURCES = \ about.h about.c \ - add_shellcode.h add_shellcode.c \ binparts.h binparts.c \ export.h export.c \ goto.h goto.c \ - plugins.h plugins.c + plugins.h plugins.c \ + shellcode.h shellcode.c libdialogs_la_LDFLAGS = diff --git a/src/dialogs/about.c b/src/dialogs/about.c index 8773e31..1a1b064 100644 --- a/src/dialogs/about.c +++ b/src/dialogs/about.c @@ -52,7 +52,7 @@ GtkWidget *create_about_dialog(GtkWindow *parent) { GtkWidget *result; /* Fenêtre à renvoyer */ - GtkStyle *style; /* Style associé à la fenêtre */ + GdkRGBA color; /* Couleur de fond noire */ GtkWidget *fixed; /* Support global */ gchar *filename; /* Chemin d'accès au fichier */ GtkWidget *image; /* Image chargée */ @@ -71,8 +71,8 @@ GtkWidget *create_about_dialog(GtkWindow *parent) gtk_window_set_default_size(GTK_WINDOW(result), 350, 430); gtk_window_set_type_hint(GTK_WINDOW(result), GDK_WINDOW_TYPE_HINT_DIALOG); - style = gtk_widget_get_style(result); - gtk_widget_modify_bg(result, GTK_STATE_NORMAL, &style->black); + gdk_rgba_parse(&color, "black"); + gtk_widget_override_background_color(GTK_WIDGET(result), GTK_STATE_FLAG_NORMAL, &color); fixed = gtk_fixed_new(); gtk_widget_show(fixed); diff --git a/src/dialogs/binparts.c b/src/dialogs/binparts.c index 14e1422..6df3d0a 100644 --- a/src/dialogs/binparts.c +++ b/src/dialogs/binparts.c @@ -279,9 +279,9 @@ GtkWidget *create_sections_dialog(GLoadedBinary *binary, GtkWindow *parent) g_signal_connect(G_OBJECT(comboboxentry), "changed", G_CALLBACK(on_model_change), ref); - gtk_combo_box_append_text(GTK_COMBO_BOX(comboboxentry), _("Default")); - gtk_combo_box_append_text(GTK_COMBO_BOX(comboboxentry), _("Routines")); - gtk_combo_box_append_text(GTK_COMBO_BOX(comboboxentry), _("User")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(comboboxentry), _("Default")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(comboboxentry), _("Routines")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(comboboxentry), _("User")); load_binary_current_parts(binary, ref); diff --git a/src/dialogs/export.c b/src/dialogs/export.c index 317ada4..a7af141 100644 --- a/src/dialogs/export.c +++ b/src/dialogs/export.c @@ -298,7 +298,7 @@ static void register_output_panel(GtkAssistant *assistant) combobox = qck_create_combobox(NULL, NULL, G_CALLBACK(NULL), NULL); gtk_box_pack_start(GTK_BOX(hbox), combobox, TRUE, TRUE, 0); - gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), _("Simple text")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox), _("Simple text")); gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 0); diff --git a/src/dialogs/export.h b/src/dialogs/export.h index fc7e1bd..dff409a 100644 --- a/src/dialogs/export.h +++ b/src/dialogs/export.h @@ -25,7 +25,7 @@ #define _DIALOGS_EXPORT_H -#include <gtk/gtkwindow.h> +#include <gtk/gtk.h> #include "../analysis/binary.h" diff --git a/src/dialogs/goto.c b/src/dialogs/goto.c index 18c364d..8a64e7e 100644 --- a/src/dialogs/goto.c +++ b/src/dialogs/goto.c @@ -157,7 +157,7 @@ GtkWidget *create_goto_dialog(GtkWindow *parent) gtk_window_set_modal(GTK_WINDOW(result), TRUE); gtk_window_set_type_hint(GTK_WINDOW(result), GDK_WINDOW_TYPE_HINT_DIALOG); - dlgvbox = GTK_DIALOG(result)->vbox; + dlgvbox = gtk_dialog_get_content_area(GTK_DIALOG(result)); gtk_widget_show(dlgvbox); vbox = gtk_vbox_new(FALSE, 8); @@ -184,7 +184,7 @@ GtkWidget *create_goto_dialog(GtkWindow *parent) - dialog_action_area1 = GTK_DIALOG(result)->action_area; + dialog_action_area1 = gtk_dialog_get_action_area(GTK_DIALOG(result)); gtk_widget_show(dialog_action_area1); gtk_button_box_set_layout(GTK_BUTTON_BOX(dialog_action_area1), GTK_BUTTONBOX_END); diff --git a/src/dialogs/add_shellcode.c b/src/dialogs/shellcode.c index ab59b36..bfde921 100644 --- a/src/dialogs/add_shellcode.c +++ b/src/dialogs/shellcode.c @@ -21,7 +21,10 @@ */ -#include "add_shellcode.h" +#include "shellcode.h" + + +#include <i18n.h> #include <malloc.h> @@ -38,9 +41,6 @@ #include "../analysis/roptions.h" // A garder ? -#ifndef _ -# define _(str) str -#endif @@ -120,7 +120,7 @@ static void register_content_panel(GtkAssistant *); * * ******************************************************************************/ -void run_add_shellcode_assistant(GStudyProject *project, GtkWindow *parent) +void run_shellcode_assistant(GStudyProject *project, GtkWindow *parent) { GtkWidget *assistant; /* Fenêtre à afficher */ GObject *ref; /* Espace de référencement */ @@ -259,10 +259,15 @@ static void register_bincode_panel(GtkAssistant *assistant) /* Réception du code */ + label = qck_create_label(NULL, NULL, _("Paste here the raw C code containing the shellcode.\r\n" + "All content between quotes will be extracted.")); + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); + scrolledwindow = gtk_scrolled_window_new(NULL, NULL); gtk_widget_show(scrolledwindow); gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow, TRUE, TRUE, 0); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow), GTK_SHADOW_IN); textview = qck_create_textview(G_OBJECT(assistant), "bincode", @@ -283,16 +288,6 @@ static void register_bincode_panel(GtkAssistant *assistant) gtk_assistant_set_page_complete(assistant, alignment, TRUE); - /* Choix par défaut */ - /* - binary = G_LOADED_BINARY(g_object_get_data(G_OBJECT(assistant), "binary")); - filename = g_loaded_binary_get_filename(binary); - - gtk_entry_set_text(GTK_ENTRY(entry), filename); - gtk_entry_append_text(GTK_ENTRY(entry), ".txt"); - - g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(on_export_filename_changed), assistant); - */ } @@ -330,6 +325,10 @@ static bool extract_shell_code(GObject *ref, bin_t **code, off_t *length) *code = NULL; *length = 0; + /* Détermination des cibles */ + + ret = regcomp(&preg, "[^'\"]*(['\"])([^'\"]*)\\1", REG_EXTENDED); + if (ret != 0) return false; /* Constitution du contexte */ @@ -339,52 +338,25 @@ static bool extract_shell_code(GObject *ref, bin_t **code, off_t *length) gtk_text_buffer_get_bounds(buffer, &start, &end); bincode = gtk_text_buffer_get_text(buffer, &start, &end, FALSE); - - printf("---- %s ----\n", bincode); - - - - /* Détermination des cibles */ - - - - ret = regcomp(&preg, "[^'\"]*(['\"])([^'\"]*)\\1", REG_EXTENDED); - - - printf("comp :: %d\n", ret); - - /* Recomposition du code */ - pos = 0; - ret = regexec(&preg, &bincode[pos], 3, pmatch, 0); while (ret != REG_NOMATCH && result) { - - bincode[pos + pmatch[2].rm_eo] = '\0'; - printf(" trouvé :: (%d ; %d) <=> %s\n", - pmatch[2].rm_so, pmatch[2].rm_eo, &bincode[pos + pmatch[2].rm_so]); - - - for (i = pos + pmatch[2].rm_so; i < (pos + pmatch[2].rm_eo) && result; i++) { *code = (bin_t *)realloc(*code, ++(*length) * sizeof(bin_t)); - printf("Trying... %d < %d\n", i, pos + pmatch[2].rm_eo); - switch (bincode[i]) { case '\\': if (++i >= (pos + pmatch[2].rm_eo)) { - printf("Exit !\n"); result = false; break; } @@ -393,14 +365,12 @@ static bool extract_shell_code(GObject *ref, bin_t **code, off_t *length) { if (++i >= (pos + pmatch[2].rm_eo)) { - printf("Exit2 !\n"); result = false; break; } if ((i + 2) > (pos + pmatch[2].rm_eo)) { - printf("Exit3 !\n"); result = false; break; } @@ -433,9 +403,6 @@ static bool extract_shell_code(GObject *ref, bin_t **code, off_t *length) } - - - g_free(bincode); if (!result && *code != NULL) @@ -443,16 +410,7 @@ static bool extract_shell_code(GObject *ref, bin_t **code, off_t *length) *length = 0; free(*code); } - /* - else if (*code != NULL) - { - *code = (bin_t *)realloc(*code, ++(*length) * sizeof(bin_t)); - (*code)[*length - 1] = '\0'; - - printf(">>> code == '%s' <<<\n", *code); - } - */ return result; } @@ -478,11 +436,12 @@ static void on_bincode_changed(GtkTextBuffer *textbuffer, GObject *ref) bool status; /* Bilan de l'extraction */ GtkLabel *label; /* Etiquette à mettre à jour */ char *markup; /* Affichage étendu */ + GtkAssistant *assistant; /* Assistant en première ligne */ + gint index; /* Indice de la page courante */ + GtkWidget *page; /* Cotenu de la page courante */ status = extract_shell_code(ref, &code, &length); - printf("extracted ! ==> %p %d -> %d\n", code, length, status); - label = GTK_LABEL(g_object_get_data(ref, "status")); if (!status) @@ -490,18 +449,31 @@ static void on_bincode_changed(GtkTextBuffer *textbuffer, GObject *ref) else if (length > 0) { - markup = g_markup_printf_escaped(_("<span color=\"#00cc00\"><b>Decoding OK (%d %s)</b></span>"), - length, length > 1 ? _("bytes") : _("byte")); + markup = g_markup_printf_escaped(_("<span color=\"#00cc00\"><b>Decoding OK (" + OFF_FMT " %s)</b></span>"), + OFF_CAST(length), length > 1 ? _("bytes") : _("byte")); gtk_label_set_markup(label, markup); g_free(markup); } else + { gtk_label_set_markup(label, _("No code")); + status = false; + } if (length > 0) free(code); + /* Poursuite des opérations ? */ + + assistant = GTK_ASSISTANT(ref); + + index = gtk_assistant_get_current_page(assistant); + page = gtk_assistant_get_nth_page(assistant, index); + + gtk_assistant_set_page_complete(assistant, page, status); + } @@ -547,9 +519,9 @@ static void register_archi_panel(GtkAssistant *assistant) gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); combobox = qck_create_combobox(G_OBJECT(assistant), "archi", G_CALLBACK(NULL), NULL); - gtk_box_pack_start(GTK_BOX(vbox), combobox, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(vbox), combobox, TRUE, FALSE, 0); - gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), _("x86")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox), _("x86")); gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 0); @@ -559,10 +531,10 @@ static void register_archi_panel(GtkAssistant *assistant) gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); combobox = qck_create_combobox(G_OBJECT(assistant), "rsize", G_CALLBACK(NULL), NULL); - gtk_box_pack_start(GTK_BOX(vbox), combobox, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(vbox), combobox, TRUE, FALSE, 0); - gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), _("32 bits")); - gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), _("16 bits")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox), _("32 bits")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox), _("16 bits")); gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 0); @@ -632,7 +604,7 @@ static void register_output_panel(GtkAssistant *assistant) combobox = qck_create_combobox(NULL, NULL, G_CALLBACK(NULL), NULL); gtk_box_pack_start(GTK_BOX(hbox), combobox, TRUE, TRUE, 0); - gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), _("Simple text")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox), _("Simple text")); gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 0); @@ -830,3 +802,24 @@ static void register_content_panel(GtkAssistant *assistant) gtk_assistant_set_page_complete(assistant, alignment, TRUE); } + + + + + + + + + /* Choix par défaut */ + /* + binary = G_LOADED_BINARY(g_object_get_data(G_OBJECT(assistant), "binary")); + filename = g_loaded_binary_get_filename(binary); + + gtk_entry_set_text(GTK_ENTRY(entry), filename); + gtk_entry_append_text(GTK_ENTRY(entry), ".txt"); + + g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(on_export_filename_changed), assistant); + */ + + + diff --git a/src/dialogs/add_shellcode.h b/src/dialogs/shellcode.h index 115507c..0a3c51a 100644 --- a/src/dialogs/add_shellcode.h +++ b/src/dialogs/shellcode.h @@ -30,7 +30,7 @@ /* Crée et affiche un assistant d'ajout de binaire. */ -void run_add_shellcode_assistant(GStudyProject *, GtkWindow *); +void run_shellcode_assistant(GStudyProject *, GtkWindow *); diff --git a/src/editor.h b/src/editor.h index 1862dbc..45b002f 100644 --- a/src/editor.h +++ b/src/editor.h @@ -26,7 +26,7 @@ #define _EDITOR_H -#include <gtk/gtkwidget.h> +#include <gtk/gtk.h> diff --git a/src/glibext/gbufferline.h b/src/glibext/gbufferline.h index 2a46b5a..7b063ac 100644 --- a/src/glibext/gbufferline.h +++ b/src/glibext/gbufferline.h @@ -113,9 +113,6 @@ typedef enum _RenderingTagType #define COL_MARGIN 23 -/* Accompagnement du dessin pour compléments */ -typedef void (* buffer_line_draw_fc) (GBufferLine *, GdkDrawable *, GdkGC *, gint, gint, void *); - /* Détermine le type de la représentation de fragments de texte en ligne. */ GType g_buffer_line_get_type(void); diff --git a/src/glibext/gcodebuffer.c b/src/glibext/gcodebuffer.c index 70064e3..8a70ad5 100644 --- a/src/glibext/gcodebuffer.c +++ b/src/glibext/gcodebuffer.c @@ -151,8 +151,6 @@ struct _GBufferView gint last_width; /* Plus grande col. de fusion */ BufferLineColumn last_merge; /* Colonne de fusion extrême */ - buffer_line_draw_fc drawing_extra; /* Fonction d'accompagnement */ - void *drawing_data; /* Donnée utilisateur */ GSList *highlighted; /* Segments mis en évidence */ }; @@ -978,33 +976,29 @@ gint g_buffer_view_get_line_height(GBufferView *view) /****************************************************************************** * * -* Paramètres : view = visualisation à consulter. * -* width = largeur requise pour une pleine visualisation. [OUT]* -* height = hauteur requise pour une pleine visualisation. [OUT]* -* addr = indique si les positions doivent être affichées. * -* code = indique si le code binaire doit être affiché. * +* Paramètres : view = visualisation à consulter. * +* addr = indique si les positions doivent être affichées. * +* code = indique si le code binaire doit être affiché. * * * -* Description : Fournit les dimensions requises par une visualisation. * +* Description : Fournit la largeur requise par une visualisation. * * * -* Retour : - * +* Retour : Dimension calculée. * * * * Remarques : - * * * ******************************************************************************/ -void g_buffer_view_get_size(GBufferView *view, gint *width, gint *height, bool addr, bool code) +gint g_buffer_view_get_width(GBufferView *view, bool addr, bool code) { + gint result; /* Taille à retourner */ gint col_width; /* Calcul selon les colonnes */ gint full_width; /* Calcul selon les fusions */ BufferLineColumn i; /* Boucle de parcours */ - size_t first; /* Première ligne intégrée */ - size_t last; /* Dernière ligne intégrée */ if (!WIDTHS_CACHED(view)) g_buffer_view_compute_required_widths(view, addr, code); - *width = view->left_text; - *height = view->line_height; + result = view->left_text; col_width = 0; full_width = 0; @@ -1041,12 +1035,40 @@ void g_buffer_view_get_size(GBufferView *view, gint *width, gint *height, bool a /* Mise en concurrence et poursuite... */ - *width += + MAX(col_width, full_width); + result += + MAX(col_width, full_width); + + return result; + +} + + + +/****************************************************************************** +* * +* Paramètres : view = visualisation à consulter. * +* * +* Description : Fournit la hauteur requise par une visualisation. * +* * +* Retour : Dimension calculée. * +* * +* Remarques : - * +* * +******************************************************************************/ + +gint g_buffer_view_get_height(const GBufferView *view) +{ + gint result; /* Taille à retourner */ + size_t first; /* Première ligne intégrée */ + size_t last; /* Dernière ligne intégrée */ + + result = view->line_height; first = g_code_buffer_get_index_from_address(view->buffer, view->start, true); last = g_code_buffer_get_index_from_address(view->buffer, view->end, false); - *height *= (last - first + 1); + result *= (last - first + 1); + + return result; } @@ -1146,6 +1168,8 @@ vmpa_t g_buffer_view_move_caret(GBufferView *view, GdkRectangle *caret, bool ctr for (i = BLC_ASSEMBLY_HEAD; i < BLC_COUNT; i++) right_pos += view->max_widths[i] + COL_MARGIN; break; + default: /* GDK_SCROLL_SMOOTH */ + break; } first = g_code_buffer_get_index_from_address(view->buffer, view->start, true); @@ -1207,6 +1231,9 @@ vmpa_t g_buffer_view_move_caret(GBufferView *view, GdkRectangle *caret, bool ctr break; + default: /* GDK_SCROLL_SMOOTH */ + break; + } if (result && !computed) @@ -1324,33 +1351,11 @@ void g_buffer_view_highlight_segments(GBufferView *view, gint x, gint y) /****************************************************************************** * * -* Paramètres : view = visualisation à mettre à jour. * -* method = procédure à appeler à chaque dessin de ligne. * -* data = donnée utilisateur à passer lors des appels. * -* * -* Description : Définit à une procédure à appeler lors des dessins de ligne. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_buffer_view_define_extra_drawing(GBufferView *view, buffer_line_draw_fc method, void *data) -{ - view->drawing_extra = method; - view->drawing_data = data; - -} - - -/****************************************************************************** -* * * Paramètres : view = visualisation à représenter. * -* event = informations liées à l'événement. * -* gc = contexte graphique à utiliser pour les pinceaux. * +* cr = contexte graphique dédié à la procédure. * * fake_x = abscisse réelle du point 0 à l'écran. * * fake_y = ordonnée réelle du point 0 à l'écran. * +* area = position et surface à traiter. * * addr = indique si les positions doivent être affichées. * * code = indique si le code binaire doit être affiché. * * * @@ -1362,42 +1367,30 @@ void g_buffer_view_define_extra_drawing(GBufferView *view, buffer_line_draw_fc m * * ******************************************************************************/ -void g_buffer_view_draw(const GBufferView *view, const GdkEventExpose *event, GdkGC *gc, gint fake_x, gint fake_y, bool addr, bool code) +void g_buffer_view_draw(const GBufferView *view, cairo_t *cr, gint fake_x, gint fake_y, const cairo_rectangle_int_t *area, bool addr, bool code) { - cairo_t *cairo; /* Gestionnaire de rendu */ gint real_x; /* Abscisse réelle pour tampon */ gint real_y; /* Ordonnée réelle pour tampon */ - size_t first; /* Première ligne visée */ size_t end; /* Dernière ligne avant limite */ size_t last; /* Dernière ligne visée + 1 */ gint y; /* Point de départ + décallage */ - - GBufferLine **lines; /* Liste des lignes à traiter */ size_t i; /* Boucle de parcours */ - - cairo = gdk_cairo_create(event->window); - - gdk_cairo_region(cairo, event->region); - cairo_clip(cairo); - real_x = fake_x + view->left_text; - real_y = fake_y + event->area.y; - - + real_y = fake_y + area->y; first = g_code_buffer_get_index_from_address(view->buffer, view->start, true); first += (real_y / view->line_height); - last = first + (event->area.height / view->line_height); - if (event->area.height % view->line_height > 0) last++; + last = first + (area->height / view->line_height); + if (area->height % view->line_height > 0) last++; end = g_code_buffer_get_index_from_address(view->buffer, view->end, false); last = MIN(last, end); - y = event->area.y - (real_y % view->line_height); + y = area->y - (real_y % view->line_height); lines = view->buffer->lines; @@ -1410,15 +1403,13 @@ void g_buffer_view_draw(const GBufferView *view, const GdkEventExpose *event, Gd view->drawing_extra(lines[i], drawable, gc, fake_x, y, view->drawing_data); */ - g_buffer_line_draw(lines[i], cairo, view->fcache, + g_buffer_line_draw(lines[i], cr, view->fcache, view->max_widths, real_x, y, addr, code); y += view->line_height; } - cairo_destroy(cairo); - } diff --git a/src/glibext/gcodebuffer.h b/src/glibext/gcodebuffer.h index 4ae5c58..e2ff8b0 100644 --- a/src/glibext/gcodebuffer.h +++ b/src/glibext/gcodebuffer.h @@ -121,8 +121,11 @@ GCodeBuffer *g_buffer_view_get_buffer(const GBufferView *); /* Fournit la hauteur d'impression d'une ligne visualisée. */ gint g_buffer_view_get_line_height(GBufferView *); -/* Fournit les dimensions requises par une visualisation. */ -void g_buffer_view_get_size(GBufferView *, gint *, gint *, bool, bool); +/* Fournit la largeur requise par une visualisation. */ +gint g_buffer_view_get_width(GBufferView *, bool, bool); + +/* Fournit la hauteur requise par une visualisation. */ +gint g_buffer_view_get_height(const GBufferView *); /* Calcule la position idéale de curseur pour un point donné. */ vmpa_t g_buffer_view_compute_caret(GBufferView *, gint, gint, GdkRectangle *); @@ -136,11 +139,8 @@ bool g_buffer_view_unhighlight_segments(GBufferView *); /* Surligne tous les segments similaires à celui sous la souris. */ void g_buffer_view_highlight_segments(GBufferView *, gint, gint); -/* Définit à une procédure à appeler lors des dessins de ligne. */ -void g_buffer_view_define_extra_drawing(GBufferView *, buffer_line_draw_fc, void *); - /* Imprime la visualisation du tampon de code désassemblé. */ -void g_buffer_view_draw(const GBufferView *, const GdkEventExpose *, GdkGC *, gint, gint, bool, bool); +void g_buffer_view_draw(const GBufferView *, cairo_t *, gint, gint, const cairo_rectangle_int_t *, bool, bool); /* Fournit la ligne présente à une ordonnée donnée. */ GBufferLine *g_buffer_view_find_line_at(GBufferView *, gint, size_t *); diff --git a/src/glibext/gfontcache.h b/src/glibext/gfontcache.h index e6ef2d6..2132a34 100644 --- a/src/glibext/gfontcache.h +++ b/src/glibext/gfontcache.h @@ -27,7 +27,7 @@ #include <glib.h> #include <glib-object.h> -#include <gtk/gtkwidget.h> +#include <gtk/gtk.h> #include <pango/pango-context.h> #include <pango/pango-font.h> diff --git a/src/gtkext/graph/edge.c b/src/gtkext/graph/edge.c index 4aedbde..8540c19 100644 --- a/src/gtkext/graph/edge.c +++ b/src/gtkext/graph/edge.c @@ -401,33 +401,6 @@ void g_graph_edge_compute(GGraphEdge *edge, GGraphRanks *ranks) /****************************************************************************** * * -* Paramètres : edge = ligne de rendu à manipuler. * -* drawable = surface de rendu à utiliser. * -* gc = contexte graphique du dessin. * -* * -* Description : Dessine les liens graphiques enregistrés dans le moteur. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_graph_edge_draw(const GGraphEdge *edge, GdkDrawable *drawable, GdkGC *gc) -{ - cairo_t *cairo; /* Gestionnaire de rendu */ - - cairo = gdk_cairo_create(drawable); - - _g_graph_edge_draw(edge, cairo, true); - - cairo_destroy(cairo); - -} - - -/****************************************************************************** -* * * Paramètres : edge = ligne de rendu à manipuler. * * cairo = assistant pour le rendu graphique. * * arrow = indique le besoin en flèche à l'arrivée. * @@ -440,7 +413,7 @@ void g_graph_edge_draw(const GGraphEdge *edge, GdkDrawable *drawable, GdkGC *gc) * * ******************************************************************************/ -void _g_graph_edge_draw(const GGraphEdge *edge, cairo_t *cairo, bool arrow) +void g_graph_edge_draw(const GGraphEdge *edge, cairo_t *cairo, bool arrow) { size_t i; /* Boucle de parcours */ diff --git a/src/gtkext/graph/edge.h b/src/gtkext/graph/edge.h index 12dcfdc..f6f0acf 100644 --- a/src/gtkext/graph/edge.h +++ b/src/gtkext/graph/edge.h @@ -77,10 +77,7 @@ void g_graph_edge_reserve_horizontal_space(GGraphEdge *, GGraphRanks *); void g_graph_edge_compute(GGraphEdge *, GGraphRanks *); /* Dessine les liens graphiques enregistrés dans le moteur. */ -void g_graph_edge_draw(const GGraphEdge *, GdkDrawable *, GdkGC *); - -/* Dessine les liens graphiques enregistrés dans le moteur. */ -void _g_graph_edge_draw(const GGraphEdge *, cairo_t *, bool); +void g_graph_edge_draw(const GGraphEdge *, cairo_t *, bool); diff --git a/src/gtkext/graph/layout.c b/src/gtkext/graph/layout.c index 9ac3ee3..0d4f7b3 100644 --- a/src/gtkext/graph/layout.c +++ b/src/gtkext/graph/layout.c @@ -789,30 +789,6 @@ void g_graph_layout_size_request(const GGraphLayout *layout, GtkRequisition *req /****************************************************************************** * * -* Paramètres : layout = graphique à représenter. * -* drawable = surface de rendu à utiliser. * -* gc = contexte graphique du dessin. * -* * -* Description : Dessine les liens graphiques enregistrés dans le moteur. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_graph_layout_draw(const GGraphLayout *layout, GdkDrawable *drawable, GdkGC *gc) -{ - size_t i; /* Boucle de parcours */ - - for (i = 0; i < layout->edges_count; i++) - g_graph_edge_draw(layout->edges[i], drawable, gc); - -} - - -/****************************************************************************** -* * * Paramètres : layout = graphique à représenter. * * cairo = assistant pour le rendu graphique. * * arrow = indique le besoin en flèche à l'arrivée. * @@ -825,11 +801,11 @@ void g_graph_layout_draw(const GGraphLayout *layout, GdkDrawable *drawable, GdkG * * ******************************************************************************/ -void _g_graph_layout_draw(const GGraphLayout *layout, cairo_t *cairo, bool arrow) +void g_graph_layout_draw(const GGraphLayout *layout, cairo_t *cairo, bool arrow) { size_t i; /* Boucle de parcours */ for (i = 0; i < layout->edges_count; i++) - _g_graph_edge_draw(layout->edges[i], cairo, arrow); + g_graph_edge_draw(layout->edges[i], cairo, arrow); } diff --git a/src/gtkext/graph/layout.h b/src/gtkext/graph/layout.h index 8aade99..6055a04 100644 --- a/src/gtkext/graph/layout.h +++ b/src/gtkext/graph/layout.h @@ -79,10 +79,7 @@ void g_graph_layout_place(GGraphLayout *, GtkGraphView *); void g_graph_layout_size_request(const GGraphLayout *, GtkRequisition *); /* Dessine les liens graphiques enregistrés dans le moteur. */ -void g_graph_layout_draw(const GGraphLayout *, GdkDrawable *, GdkGC *); - -/* Dessine les liens graphiques enregistrés dans le moteur. */ -void _g_graph_layout_draw(const GGraphLayout *, cairo_t *, bool); +void g_graph_layout_draw(const GGraphLayout *, cairo_t *, bool); 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); diff --git a/src/gtkext/gtkblockview.h b/src/gtkext/gtkblockview.h index c3e04ed..e67b8d5 100644 --- a/src/gtkext/gtkblockview.h +++ b/src/gtkext/gtkblockview.h @@ -26,7 +26,7 @@ #include <glib-object.h> -#include <gtk/gtkwidget.h> +#include <gtk/gtk.h> diff --git a/src/gtkext/gtkbufferview.c b/src/gtkext/gtkbufferview.c index 7cb1e9b..877b041 100644 --- a/src/gtkext/gtkbufferview.c +++ b/src/gtkext/gtkbufferview.c @@ -46,14 +46,17 @@ static gboolean gtk_buffer_view_focus(GtkWidget *, GtkDirectionType); /* Assure la gestion des clics de souris sur le composant. */ static gboolean gtk_buffer_view_button_press(GtkWidget *, GdkEventButton *); -/* Fournit la taille de composant requise pour un plein rendu. */ -static void gtk_buffer_view_size_request(GtkWidget *, GtkRequisition *); +/* Fournit la hauteur de composant requise pour un plein rendu. */ +static void gtk_buffer_view_get_preferred_height(GtkWidget *, gint *, gint *); + +/* Fournit la largeur de composant requise pour un plein rendu. */ +static void gtk_buffer_view_get_preferred_width(GtkWidget *, gint *, gint *); /* S'adapte à la surface concédée par le composant parent. */ static void gtk_buffer_view_size_allocate(GtkWidget *, GtkAllocation *); /* Met à jour l'affichage de la visualisation de code buffer. */ -static gboolean gtk_buffer_view_expose(GtkWidget *, GdkEventExpose *); +static gboolean gtk_buffer_view_draw(GtkWidget *, cairo_t *); /* Prend en compte une frappe de touche sur le composant. */ static gboolean gtk_buffer_view_key_press(GtkWidget *, GdkEventKey *); @@ -109,9 +112,10 @@ static void gtk_buffer_view_class_init(GtkBufferViewClass *class) widget_class->focus = gtk_buffer_view_focus; widget_class->button_press_event = gtk_buffer_view_button_press; - widget_class->size_request = gtk_buffer_view_size_request; + widget_class->get_preferred_height = gtk_buffer_view_get_preferred_height; + widget_class->get_preferred_width = gtk_buffer_view_get_preferred_width; widget_class->size_allocate = gtk_buffer_view_size_allocate; - widget_class->expose_event = gtk_buffer_view_expose; + widget_class->draw = gtk_buffer_view_draw; widget_class->key_press_event = gtk_buffer_view_key_press; g_signal_new("caret-moved", @@ -301,10 +305,11 @@ void gtk_buffer_view_compute_real_coord(GtkBufferView *view, gint *x, gint *y) /****************************************************************************** * * -* Paramètres : widget = composant GTK à consulter. * -* requisition = dimensions souhaitées. [OUT] * +* Paramètres : widget = composant GTK à consulter. * +* minimal = taille minimale. [OUT] * +* natural = taille idéale. [OUT] * * * -* Description : Fournit la taille de composant requise pour un plein rendu. * +* Description : Fournit la hauteur de composant requise pour un plein rendu. * * * * Retour : - * * * @@ -312,17 +317,50 @@ void gtk_buffer_view_compute_real_coord(GtkBufferView *view, gint *x, gint *y) * * ******************************************************************************/ -static void gtk_buffer_view_size_request(GtkWidget *widget, GtkRequisition *requisition) +static void gtk_buffer_view_get_preferred_height(GtkWidget *widget, gint *minimal, gint *natural) { GtkBufferView *view; /* Autre version du composant */ view = GTK_BUFFER_VIEW(widget); if (view->buffer_view != NULL) - g_buffer_view_get_size(view->buffer_view, - &requisition->width, &requisition->height, - *GTK_VIEW_PANEL(view)->display_addr, - *GTK_VIEW_PANEL(view)->display_code); + *minimal = g_buffer_view_get_height(view->buffer_view); + else + *minimal = 0; + + *natural = *minimal; + +} + + +/****************************************************************************** +* * +* Paramètres : widget = composant GTK à consulter. * +* minimal = taille minimale. [OUT] * +* natural = taille idéale. [OUT] * +* * +* Description : Fournit la largeur de composant requise pour un plein rendu. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_buffer_view_get_preferred_width(GtkWidget *widget, gint *minimal, gint *natural) +{ + GtkBufferView *view; /* Autre version du composant */ + + view = GTK_BUFFER_VIEW(widget); + + if (view->buffer_view != NULL) + *minimal = g_buffer_view_get_width(view->buffer_view, + *GTK_VIEW_PANEL(view)->display_addr, + *GTK_VIEW_PANEL(view)->display_code); + else + *minimal = 0; + + *natural = *minimal; } @@ -351,10 +389,10 @@ static void gtk_buffer_view_size_allocate(GtkWidget *widget, GtkAllocation *allo /* Mise à jour GTK */ - widget->allocation = *allocation; + gtk_widget_set_allocation(widget, allocation); if (gtk_widget_get_realized(widget)) - gdk_window_move_resize(widget->window, + gdk_window_move_resize(gtk_widget_get_window(widget), allocation->x, allocation->y, allocation->width, allocation->height); @@ -365,18 +403,18 @@ static void gtk_buffer_view_size_allocate(GtkWidget *widget, GtkAllocation *allo view = GTK_BUFFER_VIEW(widget); - g_buffer_view_get_size(view->buffer_view, &width, &height, - *panel->display_addr, *panel->display_code); + width = g_buffer_view_get_width(view->buffer_view, *panel->display_addr, *panel->display_code); + height = g_buffer_view_get_height(view->buffer_view); gtk_view_panel_compute_allocation(panel, &valloc); /* Défilement horizontal */ - panel->hadjustment->page_size = valloc.width; - panel->hadjustment->step_increment = valloc.width * 0.1; - panel->hadjustment->page_increment = valloc.width * 0.9; + gtk_adjustment_set_page_size(panel->hadjustment, valloc.width); + gtk_adjustment_set_step_increment(panel->hadjustment, valloc.width * 0.1); + gtk_adjustment_set_page_increment(panel->hadjustment, valloc.width * 0.9); - panel->hadjustment->upper = MAX(width, valloc.width); + gtk_adjustment_set_upper(panel->hadjustment, MAX(width, valloc.width)); gtk_view_panel_reclamp_adjustment(panel->hadjustment, &changed); @@ -387,11 +425,11 @@ static void gtk_buffer_view_size_allocate(GtkWidget *widget, GtkAllocation *allo /* Défilement vertical */ - panel->vadjustment->page_size = valloc.height; - panel->vadjustment->step_increment = view->line_height; - panel->vadjustment->page_increment = panel->vadjustment->step_increment * 10.0; + gtk_adjustment_set_page_size(panel->vadjustment, valloc.height); + gtk_adjustment_set_step_increment(panel->vadjustment, view->line_height); + gtk_adjustment_set_page_increment(panel->vadjustment, view->line_height * 10.0); - panel->vadjustment->upper = MAX(height, valloc.height); + gtk_adjustment_set_upper(panel->vadjustment, MAX(height, valloc.height)); gtk_view_panel_reclamp_adjustment(panel->vadjustment, &changed); @@ -405,8 +443,8 @@ static void gtk_buffer_view_size_allocate(GtkWidget *widget, GtkAllocation *allo /****************************************************************************** * * -* Paramètres : view = composant GTK à redessiner. * -* event = informations liées à l'événement. * +* Paramètres : widget = composant GTK à redessiner. * +* cr = contexte graphique associé à l'événement. * * * * Description : Met à jour l'affichage de la visualisation de code buffer. * * * @@ -416,62 +454,75 @@ static void gtk_buffer_view_size_allocate(GtkWidget *widget, GtkAllocation *allo * * ******************************************************************************/ -static gboolean gtk_buffer_view_expose(GtkWidget *widget, GdkEventExpose *event) +static gboolean gtk_buffer_view_draw(GtkWidget *widget, cairo_t *cr) { GtkBufferView *view; /* Autre version du composant */ GtkViewPanel *pview; /* Autre version du composant */ - GtkStyle *style; /* Style associé au composant */ - GdkDrawable *drawable; /* Surface de dessin */ + cairo_region_t *region; /* Région visible à redessiner */ + cairo_rectangle_int_t area; /* Surface correspondante */ gint fake_x; /* Abscisse virtuelle */ gint fake_y; /* Ordonnée virtuelle */ - GtkStateType state; /* Etat du composant */ - GtkViewPanelClass *parent_class; /* Version pure du parent */ + GtkStateFlags state; /* Etat du composant */ + GdkRGBA *color; /* Couleur du curseur */ view = GTK_BUFFER_VIEW(widget); widget = GTK_WIDGET(view); pview = GTK_VIEW_PANEL(widget); - drawable = GDK_DRAWABLE(event->window); - - gdk_window_begin_paint_region(drawable, event->region); - - //gdk_gc_set_clip_region(pview->gc, event->region); - - style = gtk_widget_get_style(GTK_WIDGET(view)); + region = gdk_window_get_visible_region(gtk_widget_get_window(widget)); + cairo_region_get_extents(region, &area); + cairo_region_destroy(region); fake_x = 0; fake_y = 0; gtk_buffer_view_compute_fake_coord(view, &fake_x, &fake_y); + + do + { + + + GtkStyleContext *context; + + + context = gtk_widget_get_style_context(widget); + + gtk_render_background(context, cr, 0, 0, 250, 250); + + printf("Passage!\n"); + + + } while (0); + + + /* Dessin de la marge gauche */ - state = gtk_widget_get_state(widget); + state = gtk_widget_get_state_flags(widget); - gdk_gc_set_foreground(pview->gc, &style->mid[state]); + gtk_style_context_get(gtk_widget_get_style_context(widget), state, + GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &color, NULL); - gdk_draw_rectangle(drawable, pview->gc, TRUE, - fake_x, event->area.y, view->left_margin, event->area.y + event->area.height); + cairo_rectangle(cr, fake_x, area.y,view->left_margin, area.y + area.height); + cairo_fill(cr); - gdk_gc_set_foreground(pview->gc, &style->dark[state]); + gtk_style_context_get(gtk_widget_get_style_context(widget), state, + GTK_STYLE_PROPERTY_BORDER_COLOR, &color, NULL); - gdk_draw_line(drawable, pview->gc, - fake_x + view->left_margin, event->area.y, - fake_x + view->left_margin, event->area.y + event->area.height); + cairo_move_to(cr, fake_x + view->left_margin, area.y); + cairo_line_to(cr, fake_x + view->left_margin, area.y + area.height); + cairo_fill(cr); /* Eventuelle bordure globale */ - parent_class = g_type_class_peek(g_type_parent(GTK_TYPE_BUFFER_VIEW)); - - GTK_WIDGET_CLASS(parent_class)->expose_event(widget, event); + GTK_WIDGET_CLASS(gtk_buffer_view_parent_class)->draw(widget, cr); /* Impression du désassemblage */ if (view->buffer_view != NULL) - g_buffer_view_draw(view->buffer_view, event, pview->gc, fake_x, fake_y, + g_buffer_view_draw(view->buffer_view, cr, fake_x, fake_y, &area, *pview->display_addr, *pview->display_code); - gdk_window_end_paint(drawable); - return TRUE; } @@ -633,7 +684,8 @@ void gtk_buffer_view_attach_buffer(GtkBufferView *view, GBufferView *buffer, boo /* Validation finale */ - g_buffer_view_get_size(view->buffer_view, &width, &height, *addr, *code); + width = g_buffer_view_get_width(view->buffer_view, *addr, *code); + height = g_buffer_view_get_height(view->buffer_view); width += -view->left_text + 1; height += 1; @@ -754,10 +806,8 @@ static gboolean gtk_buffer_view_refresh_caret(GtkBufferView *view) { GtkWidget *widget; /* Autre version du composant */ GdkRectangle area; /* Région adaptée à traiter */ - GdkDrawable *drawable; /* Surface de dessin */ - GtkStyle *style; /* Style associé au composant */ - GtkStateType state; /* Etat du composant */ - GdkGC *gc; /* Contexte graphique */ + cairo_t *cr; /* Contexte graphique */ + GdkRGBA *color; /* Couleur du curseur */ widget = GTK_WIDGET(view); @@ -776,16 +826,18 @@ static gboolean gtk_buffer_view_refresh_caret(GtkBufferView *view) { view->show_caret = true; - drawable = GDK_DRAWABLE(widget->window); - state = gtk_widget_get_state(widget); - style = gtk_widget_get_style(widget); + cr = gdk_cairo_create(gtk_widget_get_window(widget)); + + gtk_style_context_get(gtk_widget_get_style_context(widget), + gtk_widget_get_state_flags(widget), + GTK_STYLE_PROPERTY_COLOR, &color, NULL); - gc = gdk_gc_new(drawable); - gdk_gc_set_foreground(gc, &style->text[state]); + cairo_set_source_rgb(cr, color->red, color->green, color->blue); - gdk_draw_rectangle(drawable, gc, TRUE, area.x, area.y, area.width, area.height); + cairo_rectangle(cr, area.x, area.y, area.width, area.height); + cairo_fill(cr); - gdk_gc_destroy(gc); + cairo_destroy(cr); } diff --git a/src/gtkext/gtkbufferview.h b/src/gtkext/gtkbufferview.h index df34b72..6b95a4c 100644 --- a/src/gtkext/gtkbufferview.h +++ b/src/gtkext/gtkbufferview.h @@ -26,7 +26,7 @@ #include <glib-object.h> -#include <gtk/gtkwidget.h> +#include <gtk/gtk.h> #include "../glibext/gcodebuffer.h" diff --git a/src/gtkext/gtkdockstation.c b/src/gtkext/gtkdockstation.c index e087377..532ea2b 100644 --- a/src/gtkext/gtkdockstation.c +++ b/src/gtkext/gtkdockstation.c @@ -47,7 +47,7 @@ static gboolean gtk_dock_station_switch_panel(GtkNotebook *, gpointer *, guint, /* Détermine le type du composant d'affichage concentré. */ -G_DEFINE_TYPE(GtkDockStation, gtk_dock_station, GTK_TYPE_VBOX) +G_DEFINE_TYPE(GtkDockStation, gtk_dock_station, GTK_TYPE_BOX) /****************************************************************************** @@ -110,11 +110,13 @@ static void gtk_dock_station_init(GtkDockStation *station) GtkWidget *button; /* Bouton de contrôle */ GtkWidget *image; /* Image associée */ + gtk_orientable_set_orientation(GTK_ORIENTABLE(station), GTK_ORIENTATION_VERTICAL); + eventbox = gtk_event_box_new(); gtk_widget_show(eventbox); gtk_box_pack_start(GTK_BOX(station), eventbox, FALSE, TRUE, 0); - hbox = gtk_hbox_new(FALSE, 0); + hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_widget_show(hbox); gtk_container_add(GTK_CONTAINER(eventbox), hbox); diff --git a/src/gtkext/gtkdockstation.h b/src/gtkext/gtkdockstation.h index 192fdf2..add421a 100644 --- a/src/gtkext/gtkdockstation.h +++ b/src/gtkext/gtkdockstation.h @@ -28,7 +28,7 @@ #include <gtk/gtk.h> -G_BEGIN_DECLS +//G_BEGIN_DECLS #define GTK_TYPE_DOCK_STATION (gtk_dock_station_get_type()) @@ -47,7 +47,7 @@ typedef struct _GtkDockStationClass GtkDockStationClass; /* Station de réception pour concentration d'éléments (instance) */ struct _GtkDockStation { - GtkVBox vbox; /* Présence obligatoire en 1er */ + GtkBox vbox; /* Présence obligatoire en 1er */ GtkLabel *title; /* Title du support principal */ GtkNotebook *notebook; /* Support à onglets */ @@ -57,7 +57,7 @@ struct _GtkDockStation /* Station de réception pour concentration d'éléments (classe) */ struct _GtkDockStationClass { - GtkVBoxClass parent_class; /* Présence obligatoire en 1er */ + GtkBoxClass parent_class; /* Présence obligatoire en 1er */ /* Signaux */ @@ -92,7 +92,7 @@ GtkWidget *gtk_dock_panel_get_widget(GtkDockStation *, gint); -G_END_DECLS +//G_END_DECLS diff --git a/src/gtkext/gtkgraphview.c b/src/gtkext/gtkgraphview.c index 52d718b..817c311 100644 --- a/src/gtkext/gtkgraphview.c +++ b/src/gtkext/gtkgraphview.c @@ -69,14 +69,17 @@ static void gtk_graph_view_class_init(GtkGraphViewClass *); /* Initialise une instance d'afficheur de code en graphique. */ static void gtk_graph_view_init(GtkGraphView *); -/* Fournit la taille de composant requise pour un plein rendu. */ -static void gtk_graph_view_size_request(GtkWidget *, GtkRequisition *); +/* Fournit la hauteur de composant requise pour un plein rendu. */ +static void gtk_graph_view_get_preferred_height(GtkWidget *, gint *, gint *); + +/* Fournit la largeur de composant requise pour un plein rendu. */ +static void gtk_graph_view_get_preferred_width(GtkWidget *, gint *, gint *); /* S'adapte à la surface concédée par le composant parent. */ static void gtk_graph_view_size_allocate(GtkWidget *, GtkAllocation *); /* Met à jour l'affichage de la vue sous forme graphique. */ -static gboolean gtk_graph_view_expose(GtkWidget *, GdkEventExpose *, GtkGraphView *); +static gboolean gtk_graph_view_draw(GtkWidget *, cairo_t *, GtkGraphView *); /* Réagit à la sélection externe d'une adresse. */ static void gtk_graph_view_define_main_address(GtkGraphView *, vmpa_t); @@ -125,7 +128,8 @@ static void gtk_graph_view_class_init(GtkGraphViewClass *klass) widget_class = (GtkWidgetClass *)klass; - widget_class->size_request = gtk_graph_view_size_request; + widget_class->get_preferred_height = gtk_graph_view_get_preferred_height; + widget_class->get_preferred_width = gtk_graph_view_get_preferred_width; widget_class->size_allocate = gtk_graph_view_size_allocate; } @@ -166,13 +170,15 @@ static void gtk_graph_view_init(GtkGraphView *view) view->support = GTK_FIXED(gtk_fixed_new()); gtk_widget_set_has_window(GTK_WIDGET(view->support), TRUE); - g_signal_connect(G_OBJECT(view->support), "expose-event", - G_CALLBACK(gtk_graph_view_expose), view); + g_signal_connect(G_OBJECT(view->support), "draw", + G_CALLBACK(gtk_graph_view_draw), view); gtk_widget_show(GTK_WIDGET(view->support)); + /* gdk_color_white(gtk_widget_get_colormap(GTK_WIDGET(view->support)), &white); gtk_widget_modify_bg(GTK_WIDGET(view->support), GTK_STATE_NORMAL, &white); + */ gtk_fixed_put(GTK_FIXED(view), GTK_WIDGET(view->support), 0, 0); @@ -182,12 +188,23 @@ static void gtk_graph_view_init(GtkGraphView *view) } + + + + + + + + + + /****************************************************************************** * * -* Paramètres : widget = composant GTK à consulter. * -* requisition = dimensions souhaitées. [OUT] * +* Paramètres : widget = composant GTK à consulter. * +* minimal = taille minimale. [OUT] * +* natural = taille idéale. [OUT] * * * -* Description : Fournit la taille de composant requise pour un plein rendu. * +* Description : Fournit la hauteur de composant requise pour un plein rendu. * * * * Retour : - * * * @@ -195,63 +212,74 @@ static void gtk_graph_view_init(GtkGraphView *view) * * ******************************************************************************/ -static void gtk_graph_view_size_request(GtkWidget *widget, GtkRequisition *requisition) +static void gtk_graph_view_get_preferred_height(GtkWidget *widget, gint *minimal, gint *natural) { - gpointer fixed_class; /* Classe parente */ GtkGraphView *view; /* Autre vision du composant */ - size_t i; /* Boucle de parcours */ - gint left_corner; /* Abscisse minimale */ - gint top_corner; /* Ordonnée minimale */ - - fixed_class = g_type_class_peek_parent(GTK_GRAPH_VIEW_GET_CLASS(widget)); - fixed_class = g_type_class_peek_parent(fixed_class); - - GTK_WIDGET_CLASS(fixed_class)->size_request(widget, requisition); + GtkRequisition requisition; /* Taille requise */ + gpointer fixed_class; /* Classe parente */ view = GTK_GRAPH_VIEW(widget); if (view->layout != NULL) - g_graph_layout_size_request(view->layout, requisition); + { + g_graph_layout_size_request(view->layout, &requisition); + *minimal = requisition.height; + *natural = *minimal; + } - //requisition->width += 65; - //requisition->height += 65; + else + { + fixed_class = g_type_class_peek_parent(GTK_GRAPH_VIEW_GET_CLASS(widget)); + fixed_class = g_type_class_peek_parent(fixed_class); - view = GTK_GRAPH_VIEW(widget); + GTK_WIDGET_CLASS(fixed_class)->get_preferred_height(widget, minimal, natural); - /* - requisition->width += GTK_VIEW_PANEL(widget)->hadjustment->value; - requisition->height += GTK_VIEW_PANEL(widget)->vadjustment->value; - */ + } -#if 0 - /** - * On s'assure de ne couper aucun lien. - */ +} - /* - for (i = 0; i < view->links_count; i++) - gtk_link_renderer_size_request(view->links[i], requisition); - */ - /** - * Traitement purement cosmétique : on ajoute la même bordure aux bords - * droit et bas. - */ +/****************************************************************************** +* * +* Paramètres : widget = composant GTK à consulter. * +* minimal = taille minimale. [OUT] * +* natural = taille idéale. [OUT] * +* * +* Description : Fournit la largeur de composant requise pour un plein rendu. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_graph_view_get_preferred_width(GtkWidget *widget, gint *minimal, gint *natural) +{ + GtkGraphView *view; /* Autre vision du composant */ + GtkRequisition requisition; /* Taille requise */ + gpointer fixed_class; /* Classe parente */ - left_corner = G_MAXINT; - top_corner = G_MAXINT; + view = GTK_GRAPH_VIEW(widget); - for (i = 0; i < view->children_count; i++) + if (view->layout != NULL) { - left_corner = MIN(left_corner, view->allocs[i].x); - top_corner = MIN(top_corner, view->allocs[i].y); + g_graph_layout_size_request(view->layout, &requisition); + + *minimal = requisition.width; + *natural = *minimal; + } - if (left_corner != G_MAXINT) requisition->width += left_corner; - if (top_corner != G_MAXINT) requisition->height += top_corner; -#endif + else + { + fixed_class = g_type_class_peek_parent(GTK_GRAPH_VIEW_GET_CLASS(widget)); + fixed_class = g_type_class_peek_parent(fixed_class); + + GTK_WIDGET_CLASS(fixed_class)->get_preferred_width(widget, minimal, natural); + + } } @@ -293,23 +321,23 @@ static void gtk_graph_view_size_allocate(GtkWidget *widget, GtkAllocation *alloc gtk_view_panel_compute_allocation(panel, &valloc); - gtk_widget_size_request(widget, &req); + gtk_widget_get_preferred_size(widget, NULL, &req); /* Correction de la taille du support */ view = GTK_GRAPH_VIEW(widget); - window = GTK_WIDGET(view->support)->window; + window = gtk_widget_get_window(GTK_WIDGET(view->support)); if (gdk_window_get_width(window) != req.width || gdk_window_get_height(window) != req.height) gdk_window_resize(window, req.width, req.height); /* Défilement horizontal */ - panel->hadjustment->page_size = valloc.width; - panel->hadjustment->step_increment = valloc.width * 0.1; - panel->hadjustment->page_increment = valloc.width * 0.9; + gtk_adjustment_set_page_size(panel->hadjustment, valloc.width); + gtk_adjustment_set_step_increment(panel->hadjustment, valloc.width * 0.1); + gtk_adjustment_set_page_increment(panel->hadjustment, valloc.width * 0.9); - panel->hadjustment->upper = MAX(req.width, valloc.width); + gtk_adjustment_set_upper(panel->hadjustment, MAX(req.width, valloc.width)); gtk_view_panel_reclamp_adjustment(panel->hadjustment, &changed); @@ -320,11 +348,11 @@ static void gtk_graph_view_size_allocate(GtkWidget *widget, GtkAllocation *alloc /* Défilement vertical */ - panel->vadjustment->page_size = valloc.height; - panel->vadjustment->step_increment = valloc.width * 0.1; - panel->vadjustment->page_increment = valloc.width * 0.9; + gtk_adjustment_set_page_size(panel->vadjustment, valloc.width); + gtk_adjustment_set_step_increment(panel->vadjustment, valloc.width * 0.1); + gtk_adjustment_set_page_increment(panel->vadjustment, valloc.width * 0.9); - panel->vadjustment->upper = MAX(req.height, valloc.height); + gtk_adjustment_set_upper(panel->vadjustment, MAX(req.height, valloc.height)); gtk_view_panel_reclamp_adjustment(panel->vadjustment, &changed); @@ -339,7 +367,7 @@ static void gtk_graph_view_size_allocate(GtkWidget *widget, GtkAllocation *alloc /****************************************************************************** * * * Paramètres : widget = composant GTK à redessiner. * -* event = informations liées à l'événement. * +* cr = contexte graphique associé à l'événement. * * view = support maître à consulter. * * * * Description : Met à jour l'affichage de la vue sous forme graphique. * @@ -350,10 +378,10 @@ static void gtk_graph_view_size_allocate(GtkWidget *widget, GtkAllocation *alloc * * ******************************************************************************/ -static gboolean gtk_graph_view_expose(GtkWidget *widget, GdkEventExpose *event, GtkGraphView *view) +static gboolean gtk_graph_view_draw(GtkWidget *widget, cairo_t *cr, GtkGraphView *view) { if (view->layout != NULL) - g_graph_layout_draw(view->layout, GDK_DRAWABLE(widget->window), GTK_VIEW_PANEL(view)->gc); + g_graph_layout_draw(view->layout, cr, true); return FALSE; @@ -508,8 +536,8 @@ static bool gtk_graph_view_get_address_coordinates(const GtkGraphView *view, vmp static void gtk_graph_view_scroll(GtkGraphView *view) { gtk_fixed_move(GTK_FIXED(view), GTK_WIDGET(view->support), - -GTK_VIEW_PANEL(view)->hadjustment->value, - -GTK_VIEW_PANEL(view)->vadjustment->value); + -gtk_adjustment_get_value(GTK_VIEW_PANEL(view)->hadjustment), + -gtk_adjustment_get_value(GTK_VIEW_PANEL(view)->vadjustment)); } @@ -548,7 +576,7 @@ static void gtk_graph_view_cache_glance(GtkGraphView *view, cairo_t *cairo, cons cairo_scale(cairo, scale, scale); if (view->layout != NULL) - _g_graph_layout_draw(view->layout, cairo, false); + g_graph_layout_draw(view->layout, cairo, false); } diff --git a/src/gtkext/gtkgraphview.h b/src/gtkext/gtkgraphview.h index ca164e8..85371f7 100644 --- a/src/gtkext/gtkgraphview.h +++ b/src/gtkext/gtkgraphview.h @@ -25,7 +25,7 @@ #define _GTKEXT_GTKGRAPHVIEW_H -#include <gtk/gtkwidget.h> +#include <gtk/gtk.h> #include "gtklinkrenderer.h" diff --git a/src/gtkext/gtklinkrenderer.c b/src/gtkext/gtklinkrenderer.c index 7ef1c37..cb24b64 100644 --- a/src/gtkext/gtklinkrenderer.c +++ b/src/gtkext/gtklinkrenderer.c @@ -31,7 +31,7 @@ /* Lien entre morceaux de code (instance) */ struct _GtkLinkRenderer { - GtkObject parent; /* A laisser en premier */ + GtkWidget/*Object*/ parent; /* A laisser en premier */ LinkColor color; /* Couleur d'impression */ GdkPoint *points; /* Points de la ligne dessinée */ @@ -43,7 +43,7 @@ struct _GtkLinkRenderer /* Lien entre morceaux de code (classe) */ struct _GtkLinkRendererClass { - GtkObjectClass parent; /* A laisser en premier */ + GtkWidgetClass/*ObjectClass*/ parent; /* A laisser en premier */ }; @@ -64,7 +64,7 @@ static void draw_link_arrow(cairo_t *, gint, gint, gint, gint); /* Détermine le type du moteur de rendu pour les liens graphiques. */ -G_DEFINE_TYPE(GtkLinkRenderer, gtk_link_renderer, GTK_TYPE_OBJECT) +G_DEFINE_TYPE(GtkLinkRenderer, gtk_link_renderer, GTK_TYPE_WIDGET/*OBJECT*/) /****************************************************************************** @@ -117,7 +117,7 @@ static void gtk_link_renderer_init(GtkLinkRenderer *view) * * ******************************************************************************/ -GtkObject *gtk_link_renderer_new(LinkColor color, GdkPoint *points, size_t count) +void/*GtkObject*/ *gtk_link_renderer_new(LinkColor color, GdkPoint *points, size_t count) { GtkLinkRenderer *result; /* Moteur de rendu à retourner */ @@ -127,7 +127,7 @@ GtkObject *gtk_link_renderer_new(LinkColor color, GdkPoint *points, size_t count result->points = points; result->count = count; - return GTK_OBJECT(result); + return /*GTK_OBJECT*/(result); } @@ -157,7 +157,7 @@ void gtk_link_renderer_size_request(const GtkLinkRenderer *renderer, GtkRequisit } - +#if 0 /****************************************************************************** * * * Paramètres : renderer = moteur de rendu à manipuler. * @@ -259,7 +259,7 @@ void _gtk_link_renderer_draw(const GtkLinkRenderer *renderer, cairo_t *cairo, bo renderer->points[renderer->count - 1].y); } - +#endif /****************************************************************************** * * diff --git a/src/gtkext/gtklinkrenderer.h b/src/gtkext/gtklinkrenderer.h index 7b78e5e..165c3b6 100644 --- a/src/gtkext/gtklinkrenderer.h +++ b/src/gtkext/gtklinkrenderer.h @@ -64,17 +64,17 @@ typedef enum _LinkColor GType gtk_link_renderer_get_type(void); /* Crée un nouveau moteur de rendu pour les liens graphiques. */ -GtkObject *gtk_link_renderer_new(LinkColor, GdkPoint *, size_t); +void/*GtkObject*/ *gtk_link_renderer_new(LinkColor, GdkPoint *, size_t); /* S'assure qu'une zone sera assez grande pour tout contenir. */ void gtk_link_renderer_size_request(const GtkLinkRenderer *, GtkRequisition *); - +#if 0 /* Dessine les liens graphiques enregistrés dans le moteur. */ void gtk_link_renderer_draw(const GtkLinkRenderer *, GdkDrawable *, GdkGC *); /* Dessine les liens graphiques enregistrés dans le moteur. */ void _gtk_link_renderer_draw(const GtkLinkRenderer *, cairo_t *, bool); - +#endif #endif /* _GTKEXT_GTKLINKRENDERER_H */ diff --git a/src/gtkext/gtksourceview.h b/src/gtkext/gtksourceview.h index e6cf37b..4ca9a9f 100644 --- a/src/gtkext/gtksourceview.h +++ b/src/gtkext/gtksourceview.h @@ -26,7 +26,7 @@ #include <glib-object.h> -#include <gtk/gtkwidget.h> +#include <gtk/gtk.h> diff --git a/src/gtkext/gtkviewpanel-int.h b/src/gtkext/gtkviewpanel-int.h index ee69673..e664d61 100644 --- a/src/gtkext/gtkviewpanel-int.h +++ b/src/gtkext/gtkviewpanel-int.h @@ -29,7 +29,7 @@ #include <stdbool.h> -#include <gtk/gtkfixed.h> +#include <gtk/gtk.h> @@ -61,7 +61,6 @@ struct _GtkViewPanel GtkAdjustment *hadjustment; /* Barre de défilement horiz. */ GtkAdjustment *vadjustment; /* Barre de défilement vert. */ - GdkGC *gc; /* Contexte graphique du rendu */ bool show_border; /* Affichage d'une bordure ? */ GLoadedBinary *binary; /* Binaire à visualiser */ diff --git a/src/gtkext/gtkviewpanel.c b/src/gtkext/gtkviewpanel.c index ef1f94d..ebcd941 100644 --- a/src/gtkext/gtkviewpanel.c +++ b/src/gtkext/gtkviewpanel.c @@ -45,7 +45,7 @@ static void gtk_view_panel_adj_value_changed(GtkAdjustment *, GtkViewPanel *); static void gtk_view_panel_realize(GtkWidget *); /* Met à jour l'affichage du composant d'affichage. */ -static gboolean gtk_view_panel_expose(GtkWidget *, GdkEventExpose *); +static gboolean gtk_view_panel_draw(GtkWidget *, cairo_t *); @@ -72,10 +72,11 @@ static void gtk_view_panel_class_init(GtkViewPanelClass *class) widget_class = GTK_WIDGET_CLASS(class); widget_class->realize = gtk_view_panel_realize; - widget_class->expose_event = gtk_view_panel_expose; + widget_class->draw = gtk_view_panel_draw; class->set_scroll_adjustments = gtk_view_panel_set_scroll_adjustments; + /* widget_class->set_scroll_adjustments_signal = g_signal_new(("set_scroll_adjustments"), GTK_TYPE_VIEW_PANEL, @@ -86,6 +87,7 @@ static void gtk_view_panel_class_init(GtkViewPanelClass *class) G_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT); + */ } @@ -184,13 +186,13 @@ void gtk_view_panel_reclamp_adjustment(GtkAdjustment *adj, gboolean *changed) { gdouble value; /* Valeur actuelle */ - value = adj->value; + value = gtk_adjustment_get_value(adj); - value = CLAMP(value, 0, adj->upper - adj->page_size); + value = CLAMP(value, 0, gtk_adjustment_get_upper(adj) - gtk_adjustment_get_page_size(adj)); - if (value != adj->value) + if (value != gtk_adjustment_get_value(adj)) { - adj->value = value; + gtk_adjustment_set_value(adj, value); *changed = TRUE; } else *changed = FALSE; @@ -214,12 +216,12 @@ void gtk_view_panel_reclamp_adjustment(GtkAdjustment *adj, gboolean *changed) void gtk_view_panel_compute_allocation(GtkViewPanel *panel, GtkAllocation *alloc) { GtkWidget *widget; /* Autre version de la vue */ - GtkAllocation *allocation; /* Raccourci d'utilisation #1 */ + GtkAllocation allocation; /* Raccourci d'utilisation #1 */ gint border_width; /* Raccourci d'utilisation #2 */ widget = GTK_WIDGET(panel); - allocation = &widget->allocation; - border_width = GTK_CONTAINER(panel)->border_width; + gtk_widget_get_allocation(widget, &allocation); + border_width = gtk_container_get_border_width(GTK_CONTAINER(panel)); alloc->x = 0; alloc->y = 0; @@ -232,8 +234,8 @@ void gtk_view_panel_compute_allocation(GtkViewPanel *panel, GtkAllocation *alloc } */ - alloc->width = MAX(1, allocation->width - alloc->x * 2 - border_width * 2); - alloc->height = MAX(1, allocation->height - alloc->y * 2 - border_width * 2); + alloc->width = MAX(1, allocation.width - alloc->x * 2 - border_width * 2); + alloc->height = MAX(1, allocation.height - alloc->y * 2 - border_width * 2); } @@ -252,17 +254,21 @@ void gtk_view_panel_compute_allocation(GtkViewPanel *panel, GtkAllocation *alloc static void gtk_view_panel_realize(GtkWidget *widget) { + GtkAllocation allocation; /* Disposition du composant */ GdkWindowAttr attributes; /* Propriétés du composant */ guint attributes_mask; /* Masque de prise en compte */ - GdkColor white; /* Couleur de fond normale */ + GdkWindow *window; /* Fenêtre du composant */ + GdkRGBA white; /* Couleur de fond normale */ + + gtk_widget_get_allocation(widget, &allocation); gtk_widget_set_realized(widget, TRUE); attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + attributes.x = allocation.x; + attributes.y = allocation.y; + attributes.width = allocation.width; + attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.event_mask = gtk_widget_get_events(widget) @@ -270,10 +276,17 @@ static void gtk_view_panel_realize(GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y; - widget->window = gdk_window_new(gtk_widget_get_parent_window(widget), - &attributes, attributes_mask); + window = gdk_window_new(gtk_widget_get_parent_window(widget), + &attributes, attributes_mask); + + gtk_widget_set_window(widget, window); - gdk_window_set_user_data(widget->window, widget); + gdk_window_set_user_data(window, widget); + + gdk_rgba_parse(&white, "white"); + gtk_widget_override_background_color(widget, GTK_STATE_FLAG_NORMAL, &white); + + /* widget->style = gtk_style_attach(widget->style, widget->window); @@ -281,6 +294,7 @@ static void gtk_view_panel_realize(GtkWidget *widget) gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &white); GTK_VIEW_PANEL(widget)->gc = gdk_gc_new(GDK_DRAWABLE(widget->window)); + */ } @@ -288,7 +302,7 @@ static void gtk_view_panel_realize(GtkWidget *widget) /****************************************************************************** * * * 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. * * * @@ -298,18 +312,29 @@ static void gtk_view_panel_realize(GtkWidget *widget) * * ******************************************************************************/ -static gboolean gtk_view_panel_expose(GtkWidget *widget, GdkEventExpose *event) +static gboolean gtk_view_panel_draw(GtkWidget *widget, cairo_t *cr) { - GtkViewPanel *panel; + GtkViewPanel *panel; /* Autre version du composant */ +#if 0 GdkGCValues values; /* Propriétés du contexte */ GtkStyle *style; /* Style associé au composant */ GtkRequisition req; /* Taille allouée à l'élément */ GtkStateType state; /* Etat du composant */ - +#endif panel = GTK_VIEW_PANEL(widget); if (panel->show_border) { + GtkStyleContext *context; + + + context = gtk_widget_get_style_context(widget); + + gtk_render_background(context, cr, 0, 0, 250, 250); + + printf("Passage!\n"); + + /* gdk_gc_get_values(panel->gc, &values); style = gtk_widget_get_style(widget); @@ -322,7 +347,7 @@ static gboolean gtk_view_panel_expose(GtkWidget *widget, GdkEventExpose *event) FALSE, 0, 0, req.width - 1, req.height - 1); gdk_gc_set_foreground(panel->gc, &values.foreground); - + */ } return FALSE; @@ -539,6 +564,7 @@ void gtk_view_panel_scroll_to_address(GtkViewPanel *panel, vmpa_t addr) gint x; /* Abscisse à garantir */ gint y; /* Ordonnée à garantir */ GtkAdjustment *adj; /* Défilement à mettre à jour */ + double limit; /* Limite à ne pas dépasser */ if (panel->define != NULL) panel->define(panel, addr); @@ -546,16 +572,18 @@ void gtk_view_panel_scroll_to_address(GtkViewPanel *panel, vmpa_t addr) if (panel->get_coordinates(panel, addr, &x, &y)) { adj = panel->hadjustment; + limit = gtk_adjustment_get_upper(adj) - gtk_adjustment_get_page_size(adj); - if (x > (adj->upper - adj->page_size)) - x = adj->upper - adj->page_size; + if (x > limit) + x = limit; gtk_adjustment_set_value(adj, x); adj = panel->vadjustment; + limit = gtk_adjustment_get_upper(adj) - gtk_adjustment_get_page_size(adj); - if (y > (adj->upper - adj->page_size)) - y = adj->upper - adj->page_size; + if (y > limit) + y = limit; gtk_adjustment_set_value(adj, y); diff --git a/src/gui/menus/project.c b/src/gui/menus/project.c index dbf61bc..19ced97 100644 --- a/src/gui/menus/project.c +++ b/src/gui/menus/project.c @@ -33,10 +33,14 @@ #include "../editem-int.h" #include "../../analysis/binaries/file.h" +#include "../../dialogs/shellcode.h" #include "../../gtkext/easygtk.h" +/* Affiche la boîte d'ajout d'un shellcode au projet courant. */ +static void mcb_project_add_shellcode(GtkMenuItem *, GMenuBar *); + /* Affiche la boîte d'ajout d'un binaire au projet courant. */ static void mcb_project_add_binary_file(GtkMenuItem *, GMenuBar *); @@ -79,6 +83,10 @@ GtkWidget *build_menu_project(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *b deepmenubar = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(submenuitem), deepmenubar); + deepmenuitem = qck_create_menu_item(NULL, NULL, _("Shellcode"), + G_CALLBACK(mcb_project_add_shellcode), bar); + gtk_container_add(GTK_CONTAINER(deepmenubar), deepmenuitem); + deepmenuitem = qck_create_menu_item(NULL, NULL, _("File"), G_CALLBACK(mcb_project_add_binary_file), bar); gtk_container_add(GTK_CONTAINER(deepmenubar), deepmenuitem); @@ -163,6 +171,92 @@ void update_menu_project_for_project(GtkWidget *widget, GStudyProject *project, * Paramètres : menuitem = élément de menu sélectionné. * * bar = barre de menu parente. * * * +* Description : Affiche la boîte d'ajout d'un shellcode au projet courant. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void mcb_project_add_shellcode(GtkMenuItem *menuitem, GMenuBar *bar) +{ + GStudyProject *project; /* Projet courant */ + GtkWindow *parent; /* Respect de la hiérarchie */ + GtkWidget *dialog; /* Boîte à afficher */ + + project = get_current_project(); + parent = GTK_WINDOW(G_EDITOR_ITEM(bar)->ref); + + dialog = NULL; + + run_shellcode_assistant(project, parent); + + //if (run_shellcode_assistant(project, parent)) == GTK_RESPONSE_ACCEPT) + { + + ; + + + } + +#if 0 + GtkWidget *dialog; /* Boîte à afficher */ + char *dir; /* Répertoire courant */ + gchar *filename; /* Nom du fichier à intégrer */ + GLoadedBinary *binary; /* Représentation chargée */ + + dialog = gtk_file_chooser_dialog_new(_("Open a binary file"), + GTK_WINDOW(G_EDITOR_ITEM(bar)->ref), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); + + if (g_study_project_get_filename(get_current_project()) != NULL) + { + dir = strdup(g_study_project_get_filename(get_current_project())); + dir = dirname(dir); + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), dir); + free(dir); + } + + if (g_study_project_get_filename(get_current_project()) != NULL) + { + dir = strdup(g_study_project_get_filename(get_current_project())); + dir = dirname(dir); + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), dir); + free(dir); + } + + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) + { + filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); + + binary = g_file_binary_new_from_file(filename); + + if (binary != NULL) + { + g_signal_connect(binary, "disassembly-done", + G_CALLBACK(g_study_project_add_loaded_binary), get_current_project()); + g_loaded_binary_analyse(binary); + } + + g_free(filename); + + } + + gtk_widget_destroy(dialog); +#endif +} + + + +/****************************************************************************** +* * +* Paramètres : menuitem = élément de menu sélectionné. * +* bar = barre de menu parente. * +* * * Description : Affiche la boîte d'ajout d'un binaire au projet courant. * * * * Retour : - * diff --git a/src/gui/panels/glance.c b/src/gui/panels/glance.c index d6a744e..b344e69 100644 --- a/src/gui/panels/glance.c +++ b/src/gui/panels/glance.c @@ -97,7 +97,7 @@ static void compute_glance_scale(GGlancePanel *); static void update_glance_panel_for_view_content(GGlancePanel *, GtkViewPanel *); /* Met à jour l'affichage de l'aperçu rapide à présenter. */ -static gboolean redraw_glance_area(GtkWidget *, GdkEventExpose *, GGlancePanel *); +static gboolean redraw_glance_area(GtkWidget *, cairo_t *, GGlancePanel *); /* Assure la gestion des clics de souris sur l'aperçu. */ static gboolean on_button_press_over_glance(GtkWidget *, GdkEventButton *, GGlancePanel *); @@ -166,7 +166,7 @@ static void g_glance_panel_init(GGlancePanel *panel) gtk_widget_set_size_request(base->widget, 300, 300); - g_signal_connect(G_OBJECT(area), "expose_event", + g_signal_connect(G_OBJECT(area), "draw", G_CALLBACK(redraw_glance_area), panel); g_signal_connect(G_OBJECT(area), "size-allocate", G_CALLBACK(on_glance_resize), panel); @@ -221,13 +221,14 @@ GEditorItem *g_glance_panel_new(GObject *ref) static void define_glance_bg(GtkWidget *widget, GGlancePanel *panel) { + /* gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &widget->style->mid[GTK_STATE_NORMAL]); panel->red = widget->style->mid[GTK_STATE_NORMAL].red / USHRT_MAX; panel->green = widget->style->mid[GTK_STATE_NORMAL].green / USHRT_MAX; panel->blue = widget->style->mid[GTK_STATE_NORMAL].blue / USHRT_MAX; - + */ } @@ -332,7 +333,7 @@ static void on_view_scroll_setup(GtkAdjustment *adj, GGlancePanel *panel) hadj = gtk_scrolled_window_get_hadjustment(panel->support); vadj = gtk_scrolled_window_get_vadjustment(panel->support); - if (hadj->page_size == 0 || vadj->page_size == 0) + if (gtk_adjustment_get_page_size(hadj) == 0 || gtk_adjustment_get_page_size(vadj) == 0) return; compute_glance_scale(panel); @@ -367,13 +368,13 @@ static void on_view_scrolled(GtkAdjustment *adj, GGlancePanel *panel) hadj = gtk_scrolled_window_get_hadjustment(panel->support); vadj = gtk_scrolled_window_get_vadjustment(panel->support); - if (hadj->page_size == 0 || vadj->page_size == 0) + if (gtk_adjustment_get_page_size(hadj) == 0 || gtk_adjustment_get_page_size(vadj) == 0) return; - panel->visible.x = panel->painting.x + hadj->value * panel->scale; - panel->visible.y = panel->painting.y + vadj->value * panel->scale; - panel->visible.width = hadj->page_size * panel->scale; - panel->visible.height = vadj->page_size * panel->scale; + panel->visible.x = panel->painting.x + gtk_adjustment_get_value(hadj) * panel->scale; + panel->visible.y = panel->painting.y + gtk_adjustment_get_value(vadj) * panel->scale; + panel->visible.width = gtk_adjustment_get_page_size(hadj) * panel->scale; + panel->visible.height = gtk_adjustment_get_page_size(vadj) * panel->scale; gtk_widget_queue_draw(G_EDITOR_ITEM(panel)->widget); @@ -427,7 +428,7 @@ static void compute_glance_scale(GGlancePanel *panel) /* Superficies niveau GTK... */ gtk_widget_get_allocation(G_EDITOR_ITEM(panel)->widget, &available); - + /* border = MIN(2, G_EDITOR_ITEM(panel)->widget->style->xthickness); if (border > 0) { @@ -441,7 +442,7 @@ static void compute_glance_scale(GGlancePanel *panel) available.y = border; available.height -= 2 * border; } - + */ /* Calcul des ratios et emplacements */ sx = (1.0 * available.width) / panel->req.width; @@ -514,7 +515,7 @@ static void update_glance_panel_for_view_content(GGlancePanel *panel, GtkViewPan /****************************************************************************** * * * Paramètres : widget = composant GTK à redessiner. * -* event = informations liées à l'événement. * +* cr = contexte graphique liées à l'événement. * * panel = informations liées au panneau associé. * * * * Description : Met à jour l'affichage de l'aperçu rapide à présenter. * @@ -525,11 +526,11 @@ static void update_glance_panel_for_view_content(GGlancePanel *panel, GtkViewPan * * ******************************************************************************/ -static gboolean redraw_glance_area(GtkWidget *widget, GdkEventExpose *event, GGlancePanel *panel) +static gboolean redraw_glance_area(GtkWidget *widget, cairo_t *cr, GGlancePanel *panel) { GtkAllocation available; /* Surface disponible totale */ cairo_t *cairo; /* Gestionnaire de rendu */ - +#if 0 /* Dessin de la bordure */ gtk_widget_get_allocation(widget, &available); @@ -564,7 +565,7 @@ static gboolean redraw_glance_area(GtkWidget *widget, GdkEventExpose *event, GGl cairo_destroy(cairo); } - +#endif return TRUE; } @@ -598,8 +599,8 @@ static gboolean on_button_press_over_glance(GtkWidget *widget, GdkEventButton *e hadj = gtk_scrolled_window_get_hadjustment(panel->support); vadj = gtk_scrolled_window_get_vadjustment(panel->support); - panel->ref_h = hadj->value; - panel->ref_v = vadj->value; + panel->ref_h = gtk_adjustment_get_value(hadj); + panel->ref_v = gtk_adjustment_get_value(vadj); panel->valid = (panel->visible.x <= panel->start_x && panel->start_x < (panel->visible.x + panel->visible.width) @@ -609,8 +610,8 @@ static gboolean on_button_press_over_glance(GtkWidget *widget, GdkEventButton *e if (panel->valid) { cursor = gdk_cursor_new(GDK_FLEUR); - gdk_window_set_cursor(widget->window, cursor); - gdk_cursor_unref(cursor); + gdk_window_set_cursor(gtk_widget_get_window(widget), cursor); + g_object_unref(G_OBJECT(cursor)); } } @@ -639,7 +640,7 @@ static gboolean on_button_release_over_glance(GtkWidget *widget, GdkEventButton if (panel->view != NULL && event->button == 1) { if (panel->valid) - gdk_window_set_cursor(widget->window, NULL); + gdk_window_set_cursor(gtk_widget_get_window(widget), NULL); } @@ -678,10 +679,12 @@ static gboolean on_mouse_motion_over_glance(GtkWidget *widget, GdkEventMotion *e hadj = gtk_scrolled_window_get_hadjustment(panel->support); vadj = gtk_scrolled_window_get_vadjustment(panel->support); - value = CLAMP(panel->ref_h + diff_x, hadj->lower, hadj->upper - hadj->page_size); + value = CLAMP(panel->ref_h + diff_x, gtk_adjustment_get_lower(hadj), + gtk_adjustment_get_upper(hadj) - gtk_adjustment_get_page_size(hadj)); gtk_adjustment_set_value(hadj, value); - value = CLAMP(panel->ref_v + diff_y, vadj->lower, vadj->upper - vadj->page_size); + value = CLAMP(panel->ref_v + diff_y, gtk_adjustment_get_lower(vadj), + gtk_adjustment_get_upper(vadj) - gtk_adjustment_get_page_size(vadj)); gtk_adjustment_set_value(vadj, value); } diff --git a/src/gui/panels/panel.c b/src/gui/panels/panel.c index b178443..a883bfa 100644 --- a/src/gui/panels/panel.c +++ b/src/gui/panels/panel.c @@ -41,6 +41,10 @@ +/* Transition vers GTK-3.x claire */ +#define GTK_IS_HPANED(p) gtk_orientable_get_orientation(GTK_ORIENTABLE(p)) == GTK_ORIENTATION_HORIZONTAL + + /* Support de fond pour les composants. */ static GtkWidget *_support; static panel_node *_nodes = NULL; diff --git a/src/gui/panels/welcome.c b/src/gui/panels/welcome.c index 018f12a..8825c52 100644 --- a/src/gui/panels/welcome.c +++ b/src/gui/panels/welcome.c @@ -110,7 +110,7 @@ static void g_welcome_panel_init(GWelcomePanel *panel) GEditorItem *base; /* Version basique d'instance */ support = gtk_handle_box_new(); - gtk_widget_modify_bg(support, GTK_STATE_NORMAL, &support->style->bg[GTK_STATE_NORMAL]); + //gtk_widget_modify_bg(support, GTK_STATE_NORMAL, &support->style->bg[GTK_STATE_NORMAL]); gtk_widget_show(support); align = gtk_alignment_new(0.5f, 0.5f, 0.0f, 0.0f); diff --git a/src/panels/panel.h b/src/panels/panel.h index 65887c7..73ef72b 100644 --- a/src/panels/panel.h +++ b/src/panels/panel.h @@ -27,7 +27,7 @@ #include <glib-object.h> -#include <gtk/gtkwidget.h> +#include <gtk/gtk.h> #include "../analysis/binary.h" diff --git a/src/project.h b/src/project.h index 384d1aa..5a8d510 100644 --- a/src/project.h +++ b/src/project.h @@ -25,8 +25,7 @@ #define _PROJECT_H -#include <gtk/gtkrecentmanager.h> -#include <gtk/gtkwidget.h> +#include <gtk/gtk.h> #include "analysis/binary.h" |