diff options
Diffstat (limited to 'src/gui/core/items.c')
-rw-r--r-- | src/gui/core/items.c | 106 |
1 files changed, 69 insertions, 37 deletions
diff --git a/src/gui/core/items.c b/src/gui/core/items.c index 71e7df0..9c82100 100644 --- a/src/gui/core/items.c +++ b/src/gui/core/items.c @@ -24,14 +24,18 @@ #include "items.h" +#include <malloc.h> +#include <string.h> + + #include "global.h" -#include "../editem-int.h" #include "../../analysis/db/items/move.h" /* Liste des éléments enregistrés */ -static GEditorItem *_editem_list = NULL; +static GEditorItem **_item_list = NULL; +static size_t _item_count = 0; /* Initialisations premières de façon unique */ static bool _first_content_change = true; @@ -60,7 +64,50 @@ static void track_cursor_on_view_panel(GLoadedPanel *, const GLineCursor *, gpoi void register_editor_item(GEditorItem *item) { - editem_list_add_tail(item, &_editem_list); + _item_list = realloc(_item_list, ++_item_count * sizeof(GEditorItem *)); + + _item_list[_item_count - 1] = item; + + g_object_ref(G_OBJECT(item)); + +} + + +/****************************************************************************** +* * +* Paramètres : target = désignation de l'élément réactif à retrouver. * +* * +* Description : Retrouve un élément reactif de l'éditeur par son nom clef. * +* * +* Retour : Elément retrouvé ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GEditorItem *find_editor_item_by_key(const char *target) +{ + GEditorItem *result; /* Elément à retourner */ + size_t i; /* Boucle de parcours */ + char *key; /* Nom d'un élément à analyser */ + + result = NULL; + + for (i = 0; i < _item_count && result == NULL; i++) + { + key = g_editor_item_get_key(_item_list[i]); + + if (strcmp(key, target) == 0) + { + result = _item_list[i]; + g_object_ref(G_OBJECT(result)); + } + + free(key); + + } + + return result; } @@ -80,7 +127,7 @@ void register_editor_item(GEditorItem *item) void change_editor_items_current_content(GLoadedContent *content) { GLoadedContent *old; /* Ancien contenu */ - GEditorItem *iter; /* Boucle de parcours */ + size_t i; /* Boucle de parcours */ old = get_current_content(); @@ -93,10 +140,8 @@ void change_editor_items_current_content(GLoadedContent *content) set_current_content(content); - editem_list_for_each(iter, _editem_list) - { - g_editor_item_change_content(iter, old, content); - } + for (i = 0; i < _item_count; i++) + g_editor_item_change_content(_item_list[i], old, content); } @@ -164,12 +209,10 @@ static void start_moving_to_cursor_in_loaded_panel(GLoadedPanel *panel, const GL static void track_cursor_on_view_panel(GLoadedPanel *panel, const GLineCursor *cursor, gpointer unused) { - GEditorItem *iter; /* Boucle de parcours */ + size_t i; /* Boucle de parcours */ - editem_list_for_each(iter, _editem_list) - { - g_editor_item_track_cursor(iter, panel, cursor); - } + for (i = 0; i < _item_count; i++) + g_editor_item_track_cursor(_item_list[i], panel, cursor); } @@ -189,7 +232,7 @@ static void track_cursor_on_view_panel(GLoadedPanel *panel, const GLineCursor *c void change_editor_items_current_view(GLoadedPanel *panel) { GLoadedPanel *old; /* Ancien affichage */ - GEditorItem *iter; /* Boucle de parcours */ + size_t i; /* Boucle de parcours */ /* Suivi des affichages */ @@ -204,10 +247,8 @@ void change_editor_items_current_view(GLoadedPanel *panel) set_current_view(panel); - editem_list_for_each(iter, _editem_list) - { - g_editor_item_change_view(iter, old, panel); - } + for (i = 0; i < _item_count; i++) + g_editor_item_change_view(_item_list[i], old, panel); /* Suivi du curseur */ @@ -254,12 +295,10 @@ void change_editor_items_current_view(GLoadedPanel *panel) void update_editor_items_current_view(GLoadedPanel *panel) { - GEditorItem *iter; /* Boucle de parcours */ + size_t i; /* Boucle de parcours */ - editem_list_for_each(iter, _editem_list) - { - g_editor_item_update_view(iter, panel); - } + for (i = 0; i < _item_count; i++) + g_editor_item_update_view(_item_list[i], panel); } @@ -280,12 +319,12 @@ void update_editor_items_current_view(GLoadedPanel *panel) void focus_cursor_in_editor_items(GLoadedContent *content, const GLineCursor *cursor, GEditorItem *source) { - GEditorItem *iter; /* Boucle de parcours */ + size_t i; /* Boucle de parcours */ - editem_list_for_each(iter, _editem_list) + for (i = 0; i < _item_count; i++) { - if (iter != source) - g_editor_item_focus_cursor(iter, content, cursor); + if (_item_list[i] != source) + g_editor_item_focus_cursor(_item_list[i], content, cursor); } } @@ -305,16 +344,9 @@ void focus_cursor_in_editor_items(GLoadedContent *content, const GLineCursor *cu void update_project_area(GStudyProject *project) { - GEditorItem *iter; /* Boucle de parcours */ - GEditorItemClass *klass; /* Classe correspondante */ - - editem_list_for_each(iter, _editem_list) - { - klass = G_EDITOR_ITEM_GET_CLASS(iter); + size_t i; /* Boucle de parcours */ - if (klass->update_project != NULL) - klass->update_project(iter, project); - - } + for (i = 0; i < _item_count; i++) + g_editor_item_update_project_area(_item_list[i], project); } |