diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/analysis/db/collection-int.h | 2 | ||||
-rw-r--r-- | src/analysis/db/collection.c | 67 | ||||
-rw-r--r-- | src/analysis/db/collection.h | 12 | ||||
-rw-r--r-- | src/gui/panels/bookmarks.c | 431 | ||||
-rw-r--r-- | src/gui/panels/bookmarks.ui | 23 |
5 files changed, 244 insertions, 291 deletions
diff --git a/src/analysis/db/collection-int.h b/src/analysis/db/collection-int.h index 0e69ff8..9c3af67 100644 --- a/src/analysis/db/collection-int.h +++ b/src/analysis/db/collection-int.h @@ -73,6 +73,8 @@ struct _GDbCollectionClass void (* state_changed) (GDbCollection *, GDbItem *); + void (* active_changed) (GDbCollection *, ActiveItemChange, GDbItem *); + }; diff --git a/src/analysis/db/collection.c b/src/analysis/db/collection.c index 4c7a496..dcab73e 100644 --- a/src/analysis/db/collection.c +++ b/src/analysis/db/collection.c @@ -127,6 +127,14 @@ static void g_db_collection_class_init(GDbCollectionClass *klass) g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT); + g_signal_new("active-changed", + G_TYPE_DB_COLLECTION, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(GDbCollectionClass, active_changed), + NULL, NULL, + g_cclosure_user_marshal_VOID__ENUM_OBJECT, + G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_OBJECT); + } @@ -587,6 +595,54 @@ GDbItem **g_db_collection_get_items(const GDbCollection *collec, size_t *count) /****************************************************************************** * * +* Paramètres : collec = ensemble d'éléments à consulter. * +* count = taille de la liste constituée. [OUT] * +* * +* Description : Renvoie la liste des éléments actifs. * +* * +* Retour : Liste d'éléments à parcourir. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GDbItem **g_db_collection_get_last_items(GDbCollection *collec, size_t *count) +{ + GDbItem **result; /* Liste à retourner */ + GList *list; /* Liste brute des éléments */ + GList *iter; /* Boucle de parcours #0 */ + size_t i; /* Boucle de parcours #1 */ + + assert(!g_rw_lock_writer_trylock(&collec->params_access)); + + list = g_hash_table_get_values(collec->last_items); + + *count = g_list_length(list); + + if (*count == 0) + result = NULL; + + else + { + result = malloc(*count * sizeof(GDbItem *)); + + for (iter = g_list_first(list), i = 0; iter != NULL; iter = g_list_next(iter), i++) + { + result[i] = iter->data; + g_object_ref(G_OBJECT(result[i])); + } + + } + + g_list_free(list); + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : collec = ensemble d'éléments à considérer. * * item = élément de collection à manipuler. * * new = précise la nature de l'élément à insérer. * @@ -632,16 +688,20 @@ static void g_db_collection_set_last_item(GDbCollection *collec, GDbItem *item, g_object_ref(G_OBJECT(prev)); if (g_db_item_get_flags(item) & DIF_ERASER) + { + g_signal_emit_by_name(collec, "active-changed", AIC_REMOVED, prev); g_hash_table_remove(collec->last_items, prev); + } else { - if (new) + if (!new) g_db_item_add_flag(item, DIF_UPDATED); g_object_ref(G_OBJECT(item)); g_object_ref(G_OBJECT(item)); + g_signal_emit_by_name(collec, "active-changed", AIC_UPDATED, item); g_hash_table_replace(collec->last_items, item, item); } @@ -657,6 +717,7 @@ static void g_db_collection_set_last_item(GDbCollection *collec, GDbItem *item, g_object_ref(G_OBJECT(item)); g_object_ref(G_OBJECT(item)); + g_signal_emit_by_name(collec, "active-changed", AIC_ADDED, item); g_hash_table_add(collec->last_items, item); } @@ -888,13 +949,17 @@ static void g_db_collection_unset_last_item(GDbCollection *collec, GDbItem *item old = collec->items[i - 1]; if (old == NULL || g_db_item_get_flags(old) & DIF_ERASER) + { + g_signal_emit_by_name(collec, "active-changed", AIC_REMOVED, item); g_hash_table_remove(collec->last_items, item); + } else { g_object_ref(G_OBJECT(old)); g_object_ref(G_OBJECT(old)); + g_signal_emit_by_name(collec, "active-changed", AIC_UPDATED, old); g_hash_table_replace(collec->last_items, old, old); } diff --git a/src/analysis/db/collection.h b/src/analysis/db/collection.h index f381af5..6c14624 100644 --- a/src/analysis/db/collection.h +++ b/src/analysis/db/collection.h @@ -95,6 +95,18 @@ void g_db_collection_lock_unlock(GDbCollection *, bool, bool); /* Renvoie la liste des éléments rassemblés. */ GDbItem **g_db_collection_get_items(const GDbCollection *, size_t *); +/* Renvoie la liste des éléments actifs. */ +GDbItem **g_db_collection_get_last_items(GDbCollection *, size_t *); + +/* Evénements concernant les éléments actifs */ +typedef enum _ActiveItemChange +{ + AIC_ADDED, /* Ajout d'un élément */ + AIC_REMOVED, /* Retrait d'un élément */ + AIC_UPDATED, /* Mise à jour d'un élément */ + +} ActiveItemChange; + /* Procède à l'ajout d'un nouvel élément dans la collection. */ bool g_db_collection_add_item(GDbCollection *, GDbItem *); diff --git a/src/gui/panels/bookmarks.c b/src/gui/panels/bookmarks.c index fe69f35..46069c1 100644 --- a/src/gui/panels/bookmarks.c +++ b/src/gui/panels/bookmarks.c @@ -38,8 +38,6 @@ #include "../panel-int.h" #include "../core/global.h" #include "../../analysis/db/items/bookmark.h" -#include "../../common/cpp.h" -#include "../../common/extstr.h" #include "../../core/params.h" #include "../../core/paths.h" #include "../../core/queue.h" @@ -121,27 +119,19 @@ static void change_bookmarks_panel_current_content(GBookmarksPanel *, GLoadedCon static void reload_bookmarks_into_treeview(GBookmarksPanel *, GLoadedBinary *); /* Met à jour une collection suite à une modification. */ -static void on_collection_content_changed(GDbCollection *, DBAction, GDbBookmark *, GBookmarksPanel *); +static void on_collection_content_changed(GDbCollection *, ActiveItemChange, GDbBookmark *, GBookmarksPanel *); /* Réagit au changement de sélection des signets. */ static void on_bookmarks_selection_change(GtkTreeSelection *, gpointer); - - -/* Actualise l'affichage des données d'un paramètre modifié. */ -static void on_config_param_modified(GCfgParam *, GBookmarksPanel *); - -/* Actualise la valeur affichée d'un paramètre de configuration. */ -static void update_config_param_value(GtkListStore *, GtkTreeIter *); - /* Etablit une comparaison entre deux lignes de paramètres. */ static gint compare_bookmarks_list_columns(GtkTreeModel *, GtkTreeIter *, GtkTreeIter *, gpointer); /* Réagit à une pression sur <Shift+F2> et simule l'édition. */ static gboolean on_key_pressed_over_params(GtkTreeView *, GdkEventKey *, GBookmarksPanel *); -/* Réagit à une édition de la valeur d'un paramètre. */ -static void on_param_value_edited(GtkCellRendererText *, gchar *, gchar *, GtkTreeStore *); +/* Réagit à une édition de la valeur d'un commentaire. */ +static void on_comment_value_edited(GtkCellRendererText *, gchar *, gchar *, GBookmarksPanel *); @@ -252,6 +242,7 @@ static void g_bookmarks_panel_init(GBookmarksPanel *panel) { GPanelItem *pitem; /* Version parente du panneau */ GtkBuilder *builder; /* Constructeur utilisé */ + GObject *crenderer; /* Moteur de rendu de colonne */ GtkTreeSortable *sortable; /* Autre vision de la liste */ /* Eléments de base */ @@ -271,6 +262,10 @@ static void g_bookmarks_panel_init(GBookmarksPanel *panel) builder = gtk_built_named_widget_get_builder(GTK_BUILT_NAMED_WIDGET(pitem->widget)); + crenderer = G_OBJECT(gtk_builder_get_object(builder, "crenderer")); + + g_object_set(crenderer, "editable", TRUE, NULL); + /* Tri de la liste */ sortable = GTK_TREE_SORTABLE(gtk_builder_get_object(builder, "store")); @@ -284,7 +279,7 @@ static void g_bookmarks_panel_init(GBookmarksPanel *panel) gtk_tree_sortable_set_sort_func(sortable, BMC_COMMENT, compare_bookmarks_list_columns, GINT_TO_POINTER(BMC_COMMENT), NULL); - gtk_tree_sortable_set_sort_column_id(sortable, BMC_COMMENT, GTK_SORT_ASCENDING); + gtk_tree_sortable_set_sort_column_id(sortable, BMC_PHYSICAL, GTK_SORT_ASCENDING); /* Préparation du menu contextuel */ @@ -293,9 +288,10 @@ static void g_bookmarks_panel_init(GBookmarksPanel *panel) /* Connexion des signaux */ gtk_builder_add_callback_symbols(builder, - "on_button_press_over_bookmarks", G_CALLBACK(on_button_press_over_bookmarks), - "on_key_pressed_over_params", G_CALLBACK(on_key_pressed_over_params), - "on_bookmarks_selection_change", G_CALLBACK(on_bookmarks_selection_change), + BUILDER_CALLBACK(on_button_press_over_bookmarks), + BUILDER_CALLBACK(on_key_pressed_over_params), + BUILDER_CALLBACK(on_comment_value_edited), + BUILDER_CALLBACK(on_bookmarks_selection_change), NULL); gtk_builder_connect_signals(builder, panel); @@ -416,12 +412,36 @@ static char *g_bookmarks_panel_get_key(const GBookmarksPanel *panel) static void change_bookmarks_panel_current_content(GBookmarksPanel *panel, GLoadedContent *old, GLoadedContent *new) { GLoadedBinary *binary; /* Autre version de l'instance */ + GDbCollection *collec; /* Collection à lister ici */ if (G_IS_LOADED_BINARY(new)) binary = G_LOADED_BINARY(new); else binary = NULL; + /* Basculement du binaire utilisé */ + + if (panel->binary != NULL) + { + collec = g_loaded_binary_find_collection(panel->binary, DBF_BOOKMARKS); + g_signal_handlers_disconnect_by_func(collec, G_CALLBACK(on_collection_content_changed), panel); + + g_object_unref(G_OBJECT(panel->binary)); + + } + + panel->binary = binary; + + if (panel->binary != NULL) + { + g_object_ref(G_OBJECT(binary)); + + collec = g_loaded_binary_find_collection(binary, DBF_BOOKMARKS); + g_signal_connect_to_main(collec, "active-changed", G_CALLBACK(on_collection_content_changed), panel, + g_cclosure_user_marshal_VOID__ENUM_OBJECT); + + } + reload_bookmarks_into_treeview(panel, binary); } @@ -448,13 +468,14 @@ static void change_bookmarks_panel_current_content(GBookmarksPanel *panel, GLoad static void reload_bookmarks_into_treeview(GBookmarksPanel *panel, GLoadedBinary *binary) { - GDbCollection *collec; /* Collection à lister ici */ GtkBuilder *builder; /* Constructeur utilisé */ GtkListStore *store; /* Modèle de gestion */ GArchProcessor *proc; /* Architecture du binaire */ MemoryDataSize msize; /* Taille par défaut */ - GList *items; /* Liste des éléments groupés */ - GList *b; /* Boucle de parcours */ + GDbCollection *collec; /* Collection à lister ici */ + size_t count; /* Taille de la liste obtenue */ + GDbItem **items; /* Liste des éléments actifs */ + size_t i; /* Boucle de parcours */ GDbBookmark *bookmark; /* Signet en cours d'étude */ const vmpa2t *addr; /* Adressse associée au signet */ VMPA_BUFFER(phys); /* Position physique */ @@ -462,29 +483,6 @@ static void reload_bookmarks_into_treeview(GBookmarksPanel *panel, GLoadedBinary const char *comment; /* Commentaire associé */ GtkTreeIter iter; /* Point d'insertion */ - /* Basculement du binaire utilisé */ - - if (panel->binary != NULL) - { - collec = g_loaded_binary_find_collection(panel->binary, DBF_BOOKMARKS); - g_signal_handlers_disconnect_by_func(collec, G_CALLBACK(on_collection_content_changed), panel); - - g_object_unref(G_OBJECT(panel->binary)); - - } - - panel->binary = binary; - - if (panel->binary != NULL) - { - g_object_ref(G_OBJECT(binary)); - - collec = g_loaded_binary_find_collection(binary, DBF_BOOKMARKS); - //g_signal_connect_to_main(collec, "content-changed", G_CALLBACK(on_collection_content_changed), panel, - // g_cclosure_user_marshal_VOID__ENUM_OBJECT); - - } - builder = gtk_built_named_widget_get_builder(GTK_BUILT_NAMED_WIDGET(G_PANEL_ITEM(panel)->widget)); store = GTK_LIST_STORE(gtk_builder_get_object(builder, "store")); @@ -493,7 +491,7 @@ static void reload_bookmarks_into_treeview(GBookmarksPanel *panel, GLoadedBinary /* Si le panneau actif ne représente pas un binaire... */ - if (binary == NULL) return; + if (panel->binary == NULL) return; /* Actualisation de l'affichage */ @@ -501,15 +499,15 @@ static void reload_bookmarks_into_treeview(GBookmarksPanel *panel, GLoadedBinary msize = g_arch_processor_get_memory_size(proc); g_object_unref(G_OBJECT(proc)); + collec = g_loaded_binary_find_collection(panel->binary, DBF_BOOKMARKS); + g_db_collection_rlock(collec); - /* - items = g_db_collection_get_items(collec); + items = g_db_collection_get_last_items(collec, &count); - for (b = g_list_first(items); b != NULL; b = g_list_next(b)) + for (i = 0; i < count; i++) { - bookmark = G_DB_BOOKMARK(b->data); - if (!g_db_item_is_enabled(G_DB_ITEM(bookmark))) continue; + bookmark = G_DB_BOOKMARK(items[i]); addr = g_db_bookmark_get_address(bookmark); @@ -518,20 +516,25 @@ static void reload_bookmarks_into_treeview(GBookmarksPanel *panel, GLoadedBinary comment = g_db_bookmark_get_comment(bookmark); - if (is_bookmark_filtered(panel, phys, virt, comment)) - continue; + if (!is_bookmark_filtered(panel, phys, virt, comment)) + { + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, + BMC_BOOKMARK, bookmark, + BMC_PICTURE, G_BOOKMARKS_PANEL_GET_CLASS(panel)->bookmark_img, + BMC_PHYSICAL, phys, + BMC_VIRTUAL, virt, + BMC_COMMENT, comment, + -1); + + } - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, - BMC_BOOKMARK, bookmark, - BMC_PICTURE, G_BOOKMARKS_PANEL_GET_CLASS(panel)->bookmark_img, - BMC_PHYSICAL, phys, - BMC_VIRTUAL, virt, - BMC_COMMENT, comment, - -1); + g_object_unref(G_OBJECT(bookmark)); } - */ + + if (items != NULL) + free(items); g_db_collection_runlock(collec); @@ -555,76 +558,80 @@ static void reload_bookmarks_into_treeview(GBookmarksPanel *panel, GLoadedBinary * * ******************************************************************************/ -static void on_collection_content_changed(GDbCollection *collec, DBAction action, GDbBookmark *bookmark, GBookmarksPanel *panel) +static void on_collection_content_changed(GDbCollection *collec, ActiveItemChange change, GDbBookmark *bookmark, GBookmarksPanel *panel) { GtkBuilder *builder; /* Constructeur utilisé */ GtkListStore *store; /* Modèle de gestion */ - - + GtkTreeModel *model; /* Modèle de gestion courant */ + GDbBookmark *displayed; /* Elément de collection */ + gboolean status; /* Bilan d'une comparaison */ GArchProcessor *proc; /* Architecture du binaire */ MemoryDataSize msize; /* Taille par défaut */ - const vmpa2t *addr; /* Adressse associée au signet */ VMPA_BUFFER(phys); /* Position physique */ VMPA_BUFFER(virt); /* Adresse virtuelle */ GtkTreeIter iter; /* Point d'insertion */ - GtkTreeModel *model; /* Modèle de gestion courant */ - GDbBookmark *displayed; /* Elément de collection */ - - builder = gtk_built_named_widget_get_builder(GTK_BUILT_NAMED_WIDGET(G_PANEL_ITEM(panel)->widget)); store = GTK_LIST_STORE(gtk_builder_get_object(builder, "store")); - if (action == DBA_ADD_ITEM \ - || (action == DBA_CHANGE_STATE && !g_db_item_has_flag(G_DB_ITEM(bookmark), DIF_DISABLED))) + switch (change) { - proc = g_loaded_binary_get_processor(panel->binary); - msize = g_arch_processor_get_memory_size(proc); - g_object_unref(G_OBJECT(proc)); + case AIC_REMOVED: + case AIC_UPDATED: - addr = g_db_bookmark_get_address(bookmark); + model = GTK_TREE_MODEL(store); - vmpa2_phys_to_string(addr, msize, phys, NULL); - vmpa2_virt_to_string(addr, msize, virt, NULL); + if (gtk_tree_model_get_iter_first(model, &iter)) + { + status = TRUE; - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, - BMC_BOOKMARK, bookmark, - BMC_PICTURE, G_BOOKMARKS_PANEL_GET_CLASS(panel)->bookmark_img, - BMC_PHYSICAL, phys, - BMC_VIRTUAL, virt, - BMC_COMMENT, g_db_bookmark_get_comment(bookmark), - -1); + do + { + gtk_tree_model_get(model, &iter, BMC_BOOKMARK, &displayed, -1); + status = g_db_item_cmp_key(G_DB_ITEM(bookmark), G_DB_ITEM(displayed)); + if (status) + gtk_list_store_remove(store, &iter); + g_object_unref(G_OBJECT(displayed)); - } + if (status) + break; - else - { - model = GTK_TREE_MODEL(store); + } + while (gtk_tree_model_iter_next(model, &iter)); + assert(status); - if (gtk_tree_model_get_iter_first(model, &iter)) - do - { - gtk_tree_model_get(model, &iter, BMC_BOOKMARK, &displayed, -1); + } - if (bookmark == displayed) - { - gtk_list_store_remove(store, &iter); - break; - } + if (change == AIC_REMOVED) + break; - g_object_unref(G_OBJECT(displayed)); + case AIC_ADDED: - } - while (gtk_tree_model_iter_next(model, &iter)); + proc = g_loaded_binary_get_processor(panel->binary); + msize = g_arch_processor_get_memory_size(proc); + g_object_unref(G_OBJECT(proc)); + + addr = g_db_bookmark_get_address(bookmark); + vmpa2_phys_to_string(addr, msize, phys, NULL); + vmpa2_virt_to_string(addr, msize, virt, NULL); + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, + BMC_BOOKMARK, bookmark, + BMC_PICTURE, G_BOOKMARKS_PANEL_GET_CLASS(panel)->bookmark_img, + BMC_PHYSICAL, phys, + BMC_VIRTUAL, virt, + BMC_COMMENT, g_db_bookmark_get_comment(bookmark), + -1); + + break; } @@ -676,130 +683,6 @@ static void on_bookmarks_selection_change(GtkTreeSelection *selection, gpointer /****************************************************************************** * * -* Paramètres : param = instance dont le contenu a évolué. * -* panel = panneau d'affichage de paramètres à mettre à jour. * -* * -* Description : Actualise l'affichage des données d'un paramètre modifié. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void on_config_param_modified(GCfgParam *param, GBookmarksPanel *panel) -{ - GtkBuilder *builder; /* Constructeur utilisé */ - GtkTreeModel *model; /* Gestionnaire de données */ - GtkTreeIter iter; /* Point de recherche */ - gboolean looping; /* Autorisation de bouclage */ - GCfgParam *item; /* Elément de la liste */ - - builder = gtk_built_named_widget_get_builder(GTK_BUILT_NAMED_WIDGET(G_PANEL_ITEM(panel)->widget)); - - model = GTK_TREE_MODEL(gtk_builder_get_object(builder, "store")); - - for (looping = gtk_tree_model_get_iter_first(model, &iter); - looping; - looping = gtk_tree_model_iter_next(model, &iter)) - { - gtk_tree_model_get(model, &iter, BMC_BOOKMARK, &item, -1); - - if (item == param) - { - update_config_param_value(GTK_LIST_STORE(model), &iter); - break; - } - - } - - g_object_unref(G_OBJECT(builder)); - -} - - -/****************************************************************************** -* * -* Paramètres : store = gestionnaire du tableau de données. * -* iter = point de modification dans les lignes. * -* param = paramètre dont la valeur est à afficher. * -* * -* Description : Actualise la valeur affichée d'un paramètre de configuration.* -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void update_config_param_value(GtkListStore *store, GtkTreeIter *iter) -{ - GCfgParam *param; /* Paramètre à consulter */ - ConfigParamState state; /* Etat du paramètre */ - char *state_desc; /* Version chaînée de l'état */ - bool boolean; /* Valeur booléenne */ - int integer; /* Valeur entière */ - char int_val[sizeof(XSTR(INT_MIN)) + 1];/* Valeur en chaîne de carac. */ - char *string; /* Chaîne de caractères */ - char *desc; /* Description à afficher */ - - gtk_tree_model_get(GTK_TREE_MODEL(store), iter, BMC_BOOKMARK, ¶m, -1); - - state = g_config_param_get_state(param); - - if (state & CPS_DEFAULT) - state_desc = strdup(_("By default")); - else - state_desc = strdup(_("Changed")); - - if (state & CPS_EMPTY) - state_desc = stradd(state_desc, _(" + empty")); - - if (state & CPS_EMPTY) - desc = ""; - - else - switch (g_config_param_get_ptype(param)) - { - case CPT_BOOLEAN: - g_config_param_get_value(param, &boolean); - desc = (boolean ? _("true") : _("false")); - break; - - case CPT_INTEGER: - g_config_param_get_value(param, &integer); - snprintf(int_val, sizeof(int_val), "%d", integer); - desc = int_val; - break; - - case CPT_STRING: - g_config_param_get_value(param, &string); - desc = (string != NULL ? string : ""); - break; - - default: - assert(false); - desc = "???"; - break; - - } - - /* - gtk_list_store_set(store, iter, - CPC_BOLD, state & CPS_DEFAULT ? 400 : 800, - CPC_STATUS, state_desc, - CPC_VALUE, desc, -1); - */ - - free(state_desc); - - g_object_unref(G_OBJECT(param)); - -} - - -/****************************************************************************** -* * * Paramètres : model = gestionnaire du tableau de données. * * a = première ligne de données à traiter. * * b = seconde ligne de données à traiter. * @@ -860,16 +743,23 @@ static gboolean on_key_pressed_over_params(GtkTreeView *treeview, GdkEventKey *e guint accel_key; /* Touche de raccourci */ GdkModifierType accel_mod; /* Modifiateurs attendus aussi */ - if (!g_generic_config_get_value(get_main_configuration(), MPK_KEYBINDINGS_EDIT, &accelerator)) - return FALSE; + if (event->keyval == GDK_KEY_Delete) + mcb_bookmarks_panel_delete(NULL, panel); + + else + { + if (!g_generic_config_get_value(get_main_configuration(), MPK_KEYBINDINGS_EDIT, &accelerator)) + return FALSE; + + if (accelerator == NULL) + return FALSE; - if (accelerator == NULL) - return FALSE; + gtk_accelerator_parse(accelerator, &accel_key, &accel_mod); - gtk_accelerator_parse(accelerator, &accel_key, &accel_mod); + if (event->keyval == accel_key && event->state == accel_mod) + mcb_bookmarks_panel_edit(NULL, panel); - if (event->keyval == accel_key && event->state == accel_mod) - mcb_bookmarks_panel_edit(NULL, panel); + } return FALSE; @@ -881,9 +771,9 @@ static gboolean on_key_pressed_over_params(GtkTreeView *treeview, GdkEventKey *e * Paramètres : renderer = moteur de rendu pour la cellule. * * path = chemin d'accès vers la cellule éditée. * * new = nouvelle valeur sous forme de texte à valider. * -* store = gestionnaire des données de la liste affichée. * +* panel = panneau d'affichage sur lequel s'appuyer. * * * -* Description : Réagit à une édition de la valeur d'un paramètre. * +* Description : Réagit à une édition de la valeur d'un commentaire. * * * * Retour : - * * * @@ -891,62 +781,40 @@ static gboolean on_key_pressed_over_params(GtkTreeView *treeview, GdkEventKey *e * * ******************************************************************************/ -static void on_param_value_edited(GtkCellRendererText *renderer, gchar *path, gchar *new, GtkTreeStore *store) +static void on_comment_value_edited(GtkCellRendererText *renderer, gchar *path, gchar *new, GBookmarksPanel *panel) { + GtkBuilder *builder; /* Constructeur utilisé */ + GtkListStore *store; /* Modèle de gestion */ GtkTreePath *tree_path; /* Chemin d'accès natif */ GtkTreeIter iter; /* Point de la modification */ - GCfgParam *param; /* Paramètre à actualiser */ - bool boolean; /* Valeur booléenne */ - int integer; /* Valeur entière */ - char *end; /* Pointeur vers '\0' final ? */ - - tree_path = gtk_tree_path_new_from_string(path); - if (tree_path == NULL) return; - - if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, tree_path)) - goto opve_bad_iter; - - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, BMC_BOOKMARK, ¶m, -1); - - switch (g_config_param_get_ptype(param)) - { - case CPT_BOOLEAN: - - if (strcmp(new, "true") != 0 && strcmp(new, "false") != 0) - goto opve_bad_value; + GDbBookmark *mark; /* Signet sélectionné */ + GDbBookmark *updater; /* Signet de mise à jour */ - boolean = (strcmp(new, "true") == 0); - g_config_param_set_value(param, boolean); + builder = gtk_built_named_widget_get_builder(GTK_BUILT_NAMED_WIDGET(G_PANEL_ITEM(panel)->widget)); - break; + store = GTK_LIST_STORE(gtk_builder_get_object(builder, "store")); - case CPT_INTEGER: + tree_path = gtk_tree_path_new_from_string(path); + if (tree_path == NULL) goto bad_path; - integer = strtol(new, &end, 10); - if (*end != '\0') goto opve_bad_value; - - g_config_param_set_value(param, integer); + if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, tree_path)) + goto bad_iter; - break; + gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, BMC_BOOKMARK, &mark, -1); - case CPT_STRING: - g_config_param_set_value(param, new); - break; + updater = g_db_bookmark_new(g_db_bookmark_get_address(mark), new); - default: - assert(false); - goto opve_bad_value; - break; + g_loaded_binary_add_to_collection(panel->binary, G_DB_ITEM(updater)); - } + g_object_unref(G_OBJECT(mark)); - opve_bad_value: + bad_iter: - g_object_unref(G_OBJECT(param)); + gtk_tree_path_free(tree_path); - opve_bad_iter: + bad_path: - gtk_tree_path_free(tree_path); + g_object_unref(G_OBJECT(builder)); } @@ -1185,7 +1053,7 @@ static void mcb_bookmarks_panel_edit(GtkMenuItem *menuitem, GBookmarksPanel *pan path = gtk_tree_model_get_path(model, &iter); gtk_tree_view_set_cursor(treeview, path, - gtk_tree_view_get_column(treeview, BMC_COMMENT - BMC_PHYSICAL), + gtk_tree_view_get_column(treeview, BMC_COMMENT - BMC_PICTURE), TRUE); gtk_tree_path_free(path); @@ -1215,17 +1083,24 @@ static void mcb_bookmarks_panel_delete(GtkMenuItem *menuitem, GBookmarksPanel *p GtkBuilder *builder; /* Constructeur utilisé */ GtkTreeView *treeview; /* Affichage de la liste */ GDbBookmark *mark; /* Signet sélectionné */ + GDbBookmark *eraser; /* Signet de suppression */ builder = gtk_built_named_widget_get_builder(GTK_BUILT_NAMED_WIDGET(G_PANEL_ITEM(panel)->widget)); treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview")); mark = get_selected_panel_bookmark(treeview, NULL); - if (mark == NULL) return; - //g_loaded_binary_remove_from_collection(panel->binary, DBF_BOOKMARKS, G_DB_ITEM(mark)); + if (mark != NULL) + { + eraser = g_db_bookmark_new(g_db_bookmark_get_address(mark), NULL); + g_db_item_add_flag(G_DB_ITEM(eraser), DIF_ERASER); - g_object_unref(G_OBJECT(mark)); + g_loaded_binary_add_to_collection(panel->binary, G_DB_ITEM(eraser)); + + g_object_unref(G_OBJECT(mark)); + + } g_object_unref(G_OBJECT(builder)); diff --git a/src/gui/panels/bookmarks.ui b/src/gui/panels/bookmarks.ui index 8ba6211..e068304 100644 --- a/src/gui/panels/bookmarks.ui +++ b/src/gui/panels/bookmarks.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.21.0 --> +<!-- Generated with glade 3.37.0 --> <interface> <requires lib="gtk+" version="3.20"/> <object class="GtkListStore" id="store"> @@ -17,16 +17,16 @@ </columns> </object> <object class="GtkOffscreenWindow"> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <child> <object class="GtkScrolledWindow" id="box"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="shadow_type">in</property> + <property name="can-focus">True</property> + <property name="shadow-type">in</property> <child> <object class="GtkTreeView" id="treeview"> <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="can-focus">True</property> <property name="model">store</property> <signal name="button-press-event" handler="on_button_press_over_bookmarks" swapped="no"/> <signal name="key-press-event" handler="on_key_pressed_over_params" swapped="no"/> @@ -45,7 +45,7 @@ <child> <object class="GtkTreeViewColumn"> <property name="title" translatable="yes">Physical address</property> - <property name="sort_column_id">2</property> + <property name="sort-column-id">2</property> <child> <object class="GtkCellRendererText"/> <attributes> @@ -57,7 +57,7 @@ <child> <object class="GtkTreeViewColumn"> <property name="title" translatable="yes">Virtual address</property> - <property name="sort_column_id">3</property> + <property name="sort-column-id">3</property> <child> <object class="GtkCellRendererText"/> <attributes> @@ -69,9 +69,11 @@ <child> <object class="GtkTreeViewColumn"> <property name="title" translatable="yes">Comment</property> - <property name="sort_column_id">4</property> + <property name="sort-column-id">4</property> <child> - <object class="GtkCellRendererText"/> + <object class="GtkCellRendererText" id="crenderer"> + <signal name="edited" handler="on_comment_value_edited" swapped="no"/> + </object> <attributes> <attribute name="text">4</attribute> </attributes> @@ -82,8 +84,5 @@ </child> </object> </child> - <child> - <placeholder/> - </child> </object> </interface> |