summaryrefslogtreecommitdiff
path: root/src/gui/editor.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-12-26 23:52:44 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-12-26 23:52:44 (GMT)
commit2c28d59fb3671c0fdd1987784076d4968c58b651 (patch)
treea301f6cd9c1fd9f92191fba7fe7b59a7e3a01b5a /src/gui/editor.c
parent67b4887317b7394d63b543aa48cb368406374103 (diff)
Created the GLoadedContent interface to load all kinds of content.
Diffstat (limited to 'src/gui/editor.c')
-rw-r--r--src/gui/editor.c90
1 files changed, 89 insertions, 1 deletions
diff --git a/src/gui/editor.c b/src/gui/editor.c
index 6785753..d1f90d5 100644
--- a/src/gui/editor.c
+++ b/src/gui/editor.c
@@ -47,6 +47,7 @@
#include "../core/global.h"
#include "../core/params.h"
#include "../gtkext/easygtk.h"
+#include "../gtkext/gtkdisplaypanel.h"
#include "../gtkext/gtkdockable.h"
#include "../gtkext/gtkdockstation.h"
#include "../gtkext/support.h"
@@ -214,6 +215,11 @@ static void notify_paned_handle_position_change(GObject *, GParamSpec *, gpointe
/* Réagit à un changement du projet principal. */
static void notify_editor_project_change(GStudyProject *, bool);
+/* Assure un positionnement initial idéal. */
+static gboolean scroll_for_the_first_time(GtkWidget *, GdkEvent *, GLoadedContent *);
+
+/* Affiche le contenu qui vient de rejoindre un projet donné. */
+void on_editor_loaded_content_added(GStudyProject *, GLoadedContent *, void *);
@@ -1612,7 +1618,12 @@ static void notify_editor_project_change(GStudyProject *project, bool new)
if (new)
{
- /* ... */
+
+ g_signal_connect(project, "content-added", G_CALLBACK(on_editor_loaded_content_added), NULL);
+
+
+
+ /* TODO : show_all()... */
}
@@ -1623,9 +1634,86 @@ static void notify_editor_project_change(GStudyProject *project, bool new)
g_study_project_hide(project);
+ g_signal_handlers_disconnect_by_func(project, G_CALLBACK(on_editor_loaded_content_added), NULL);
+
}
}
+
+
+/******************************************************************************
+* *
+* Paramètres : project = project impliqué dans l'opération. *
+* content = nouveau contenu à présenter dans l'éditeur. *
+* unused = adresse non utilisée ici. *
+* *
+* Description : Affiche le contenu qui vient de rejoindre un projet donné. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void on_editor_loaded_content_added(GStudyProject *project, GLoadedContent *content, void *unused)
+{
+ GtkWidget *selected; /* Interface de prédilection */
+ const char *name; /* Titre associé au binaire */
+ const char *lname; /* Description du binaire */
+ GPanelItem *panel; /* Nouveau panneau à integrer */
+
+ selected = g_loaded_content_build_view(content, 0);
+
+ name = g_loaded_content_describe(content, false);
+ lname = g_loaded_content_describe(content, true);
+
+ panel = g_panel_item_new(PIP_BINARY_VIEW, name, lname, selected, true, "N");
+ register_panel_item(panel, get_main_configuration());
+
+ g_signal_connect(selected, "size-allocate", G_CALLBACK(scroll_for_the_first_time), content);
+
+ g_panel_item_dock(panel);
+
+ update_project_area(project);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : widget = composant d'affichage nouvellement porté à l'écran.*
+* event = informations liées à l'événement. *
+* content = contenu chargé associé au composant d'affichage. *
+* *
+* Description : Assure un positionnement initial idéal. *
+* *
+* Retour : FALSE. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static gboolean scroll_for_the_first_time(GtkWidget *widget, GdkEvent *event, GLoadedContent *content)
+{
+ GExeFormat *format; /* Format associé au binaire */
+ vmpa2t target; /* Position initiale à viser */
+
+ g_signal_handlers_disconnect_by_func(widget, G_CALLBACK(scroll_for_the_first_time), content);
+
+ if (G_IS_LOADED_BINARY(content))
+ {
+ format = g_loaded_binary_get_format(G_LOADED_BINARY(content));
+
+ if (g_exe_format_get_main_address(format, &target))
+ gtk_display_panel_request_move(GTK_DISPLAY_PANEL(widget), &target);
+
+ g_object_unref(G_OBJECT(format));
+
+ }
+
+ return FALSE;
+
+}