diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2014-10-16 22:04:29 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2014-10-16 22:04:29 (GMT) |
commit | 6d34dbbb00da0c276261d0e1ce4bf862f22fd8e0 (patch) | |
tree | a5d3c8644691934ba84a91919f7db177f70743f1 /src/gui/panels | |
parent | e75f44a99c8f984af4c47fa9a2c8e7e9841700d8 (diff) |
Stored a bookmark into the data base and saved the archive.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@414 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/gui/panels')
-rw-r--r-- | src/gui/panels/bookmarks.c | 166 |
1 files changed, 85 insertions, 81 deletions
diff --git a/src/gui/panels/bookmarks.c b/src/gui/panels/bookmarks.c index 56e7119..5d2be18 100644 --- a/src/gui/panels/bookmarks.c +++ b/src/gui/panels/bookmarks.c @@ -110,6 +110,8 @@ static void g_bookmarks_panel_finalize(GBookmarksPanel *); /* Recharge une collection de signets à l'affichage. */ static void reload_bookmarks_into_treeview(GBookmarksPanel *, GLoadedBinary *); +/* Réagit au changement de sélection des signets. */ +static void on_bookmarks_selection_change(GtkTreeSelection *, GBookmarksPanel *); @@ -234,6 +236,7 @@ static void g_bookmarks_panel_init(GBookmarksPanel *panel) GtkCellRenderer *renderer; /* Moteur de rendu de colonne */ GtkTreeViewColumn *column; /* Colonne de la liste */ GtkTreeSortable *sortable; /* Autre vision de la liste */ + GtkTreeSelection *select; /* Sélection dans la liste */ base = G_EDITOR_ITEM(panel); @@ -294,7 +297,7 @@ static void g_bookmarks_panel_init(GBookmarksPanel *panel) renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes(_("Physical address"), renderer, - "text", BMC_VIRTUAL, + "text", BMC_PHYSICAL, NULL); gtk_tree_view_column_set_sort_column_id(column, BMC_PHYSICAL); gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); @@ -330,6 +333,12 @@ static void g_bookmarks_panel_init(GBookmarksPanel *panel) gtk_tree_sortable_set_sort_column_id(sortable, BMC_COMMENT, GTK_SORT_ASCENDING); + /* Prise en compte de la sélection */ + + select = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); + gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE); + g_signal_connect(G_OBJECT(select), "changed", G_CALLBACK(on_bookmarks_selection_change), panel); + /* Préparation du menu contextuel */ panel->menu = build_bookmarks_panel_menu(panel); @@ -464,14 +473,17 @@ static void reload_bookmarks_into_treeview(GBookmarksPanel *panel, GLoadedBinary { GtkTreeStore *store; /* Modèle de gestion */ GDbCollection *collec; /* Collection à lister ici */ + GExeFormat *format; /* Format du fichier binaire */ + GArchProcessor *proc; /* Architecture du binaire */ + MemoryDataSize msize; /* Taille par défaut */ GList *items; /* Liste des éléments groupés */ GList *b; /* Boucle de parcours */ GDbBookmark *bookmark; /* Signet en cours d'étude */ - vmpa2t *addr; /* Adressse associée au signet */ + const vmpa2t *addr; /* Adressse associée au signet */ + VMPA_BUFFER(phys); /* Position physique */ + VMPA_BUFFER(virt); /* Adresse virtuelle */ GtkTreeIter iter; /* Point d'insertion */ - printf("RELOAD :: %p\n", binary); - /* Basculement du binaire utilisé */ if (panel->binary != NULL) @@ -491,7 +503,10 @@ static void reload_bookmarks_into_treeview(GBookmarksPanel *panel, GLoadedBinary /* Actualisation de l'affichage */ - sleep(1); + format = g_loaded_binary_get_format(binary); + proc = get_arch_processor_from_format(format); + + msize = g_arch_processor_get_memory_size(proc); collec = g_loaded_binary_find_collection(binary, DBF_BOOKMARKS); @@ -499,107 +514,65 @@ static void reload_bookmarks_into_treeview(GBookmarksPanel *panel, GLoadedBinary items = g_db_collection_list_items(collec); - - printf(" ... items = %p\n", items); - - /* - gtk_tree_store_append(store, &iter, NULL); - gtk_tree_store_set(store, &iter, - BMC_BOOKMARK, bookmark, - BMC_PICTURE, G_BOOKMARKS_PANEL_GET_CLASS(panel)->bookmark_img, - BMC_PHYSICAL, "0x01", - BMC_VIRTUAL, "0x02", - BMC_COMMENT, "desc", - -1); - */ - - for (b = g_list_first(items); b != NULL; b = g_list_next(b)) { bookmark = G_DB_BOOKMARK(b->data); - - printf("Adding // %p\n", bookmark); - - //printf("add.virt = %s\n", vmpa2_virt_to_string(&addr, MDS_32_BITS)); - - fflush(NULL); - - addr = g_db_bookmark_get_address(bookmark); + vmpa2_phys_to_string(addr, msize, phys, NULL); + vmpa2_virt_to_string(addr, msize, virt, NULL); + gtk_tree_store_append(store, &iter, NULL); gtk_tree_store_set(store, &iter, BMC_BOOKMARK, bookmark, BMC_PICTURE, G_BOOKMARKS_PANEL_GET_CLASS(panel)->bookmark_img, - BMC_PHYSICAL, "vmpa2_phy_to_string(addr, MDS_32_BITS)", /* FIXME : pareil qu'en bas */ - BMC_VIRTUAL, "vmpa2_virt_to_string(&addr, MDS_32_BITS)", /* FIXME : choisir en fonction de l'architecture */ - BMC_COMMENT, "g_db_bookmark_get_comment(bookmark)", + BMC_PHYSICAL, phys, + BMC_VIRTUAL, virt, + BMC_COMMENT, g_db_bookmark_get_comment(bookmark), -1); } g_db_collection_runlock(collec); +} -#if 0 - GtkTreeStore *store; /* Modèle de gestion */ - GList *params; /* Paramètres de configuration */ - GCfgParam *param; /* Paramètre en cours d'étude */ - GList *p; /* Boucle de parcours */ - char *type_desc; /* Type de paramètre */ - GtkTreeIter iter; /* Point d'insertion */ - - store = GTK_TREE_STORE(gtk_tree_view_get_model(panel->treeview)); - gtk_tree_store_clear(store); - - g_generic_config_rlock(config); +/****************************************************************************** +* * +* Paramètres : selection = sélection modifiée. * +* panel = structure contenant les informations maîtresses. * +* * +* Description : Réagit au changement de sélection des signets. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ - params = g_generic_config_list_params(config); +static void on_bookmarks_selection_change(GtkTreeSelection *selection, GBookmarksPanel *panel) +{ + GtkTreeIter iter; /* Point de sélection */ + GtkTreeModel *model; /* Modèle de gestion */ + GDbBookmark *bookmark; /* Signet en cours d'étude */ + const vmpa2t *addr; /* Adressse associée au signet */ + GtkViewPanel *vpanel; /* Afficheur effectif de code */ - for (p = g_list_first(params); p != NULL; p = g_list_next(p)) + if (gtk_tree_selection_get_selected(selection, &model, &iter)) { - param = G_CFG_PARAM(p->data); + gtk_tree_model_get(model, &iter, BMC_BOOKMARK, &bookmark, -1); - if (is_param_filtered(panel, g_config_param_get_path(param))) - continue; - - switch (g_config_param_get_ptype(param)) - { - case CPT_BOOLEAN: - type_desc = _("Boolean"); - break; - - case CPT_INTEGER: - type_desc = _("Integer"); - break; - - case CPT_STRING: - type_desc = _("String"); - break; - - default: - type_desc = _("<Unknown type>"); - break; - - } - - gtk_tree_store_append(store, &iter, NULL); - gtk_tree_store_set(store, &iter, - CPC_BOOKMARK, param, - CPC_PATH, g_config_param_get_path(param), - CPC_TYPE, type_desc, - -1); + addr = g_db_bookmark_get_address(bookmark); - update_config_param_value(store, &iter); + vpanel = g_editor_item_get_current_view(G_EDITOR_ITEM(panel)); + gtk_view_panel_scroll_to_address(vpanel, addr); - g_signal_connect(param, "modified", G_CALLBACK(on_config_param_modified), panel); + g_object_unref(G_OBJECT(bookmark)); } - g_generic_config_runlock(config); -#endif } @@ -1008,8 +981,39 @@ static bool is_param_filtered(GBookmarksPanel *panel, const char *name) static gboolean on_button_press_over_bookmarks(GtkWidget *widget, GdkEventButton *event, GBookmarksPanel *panel) { - if (event->button == 3) - gtk_menu_popup(panel->menu, NULL, NULL, NULL, NULL, event->button, event->time); + GtkTreeSelection *selection; /* Sélection courante */ + GtkTreeIter iter; /* Point de sélection */ + GtkTreeModel *model; /* Modèle de gestion */ + GDbBookmark *bookmark; /* Signet en cours d'étude */ + const vmpa2t *addr; /* Adressse associée au signet */ + GtkViewPanel *vpanel; /* Afficheur effectif de code */ + + switch (event->button) + { + case 1: + + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); + + if (gtk_tree_selection_get_selected(selection, &model, &iter)) + { + gtk_tree_model_get(model, &iter, BMC_BOOKMARK, &bookmark, -1); + + addr = g_db_bookmark_get_address(bookmark); + + vpanel = g_editor_item_get_current_view(G_EDITOR_ITEM(panel)); + gtk_view_panel_scroll_to_address(vpanel, addr); + + g_object_unref(G_OBJECT(bookmark)); + + } + + break; + + case 3: + gtk_menu_popup(panel->menu, NULL, NULL, NULL, NULL, event->button, event->time); + break; + + } return FALSE; |