summaryrefslogtreecommitdiff
path: root/src/gtkext/gtkgraphdisplay.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-12-20 22:12:28 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-12-20 22:12:28 (GMT)
commitcffbe4839da452af215f05dfb7cc6c9304c1285e (patch)
treed2ea78b67592e868ed94ab189722670379cd2b67 /src/gtkext/gtkgraphdisplay.c
parent0f58e137ff493ab38d2a7e6e2d5e5bc85951be3d (diff)
Kept the current location when switching views.
Diffstat (limited to 'src/gtkext/gtkgraphdisplay.c')
-rw-r--r--src/gtkext/gtkgraphdisplay.c58
1 files changed, 54 insertions, 4 deletions
diff --git a/src/gtkext/gtkgraphdisplay.c b/src/gtkext/gtkgraphdisplay.c
index 955f540..6187677 100644
--- a/src/gtkext/gtkgraphdisplay.c
+++ b/src/gtkext/gtkgraphdisplay.c
@@ -637,6 +637,7 @@ static void gtk_graph_display_define_main_address(GtkGraphDisplay *display, cons
gint right; /* Abscisse du coin droit */
gint bottom; /* Ordonnée du coin inférieur */
GtkAllocation allocation; /* Espace alloué au panneau */
+ GtkWidget *child; /* Composant sélectionné */
if (display->routine == NULL)
need_update = true;
@@ -694,6 +695,16 @@ static void gtk_graph_display_define_main_address(GtkGraphDisplay *display, cons
gtk_graph_display_update_support_margins(display, &allocation);
+ /**
+ * Première sélection...
+ */
+
+ child = g_graph_cluster_get_widget(display->cluster);
+
+ gtk_container_set_focus_child(GTK_CONTAINER(display->support), child);
+
+ g_object_unref(G_OBJECT(child));
+
ggddma_bad_type:
g_object_unref(G_OBJECT(symbol));
@@ -746,9 +757,42 @@ static const vmpa2t *gtk_graph_display_get_caret_location(const GtkGraphDisplay
static bool gtk_graph_display_get_cursor_coordinates(const GtkGraphDisplay *display, const GLineCursor *cursor, gint *x, gint *y, ScrollPositionTweak tweak)
{
- /* TODO */
+ bool result; /* Bilan final à retourner */
+ GList *children; /* Sous-composants à parcourir */
+ GList *iter; /* Boucle de parcours */
+ GtkWidget *child; /* Composant embarqué */
+ GtkAllocation alloc; /* Emplacement réservé */
+
+ result = false;
+
+ children = gtk_container_get_children(GTK_CONTAINER(display->support));
- return false;
+ for (iter = g_list_first(children); iter != NULL; iter = g_list_next(iter))
+ {
+ child = GTK_WIDGET(iter->data);
+
+ if (!GTK_IS_BUFFER_DISPLAY(child))
+ continue;
+
+ result = gtk_buffer_display_contains_cursor(GTK_BUFFER_DISPLAY(child), cursor);
+
+ if (result)
+ {
+ result = gtk_display_panel_get_cursor_coordinates(GTK_DISPLAY_PANEL(child), cursor, x, y, tweak);
+ assert(result);
+
+ gtk_widget_get_allocation(child, &alloc);
+
+ *x += alloc.x;
+ *y += alloc.y;
+ break;
+ }
+
+ }
+
+ g_list_free(children);
+
+ return result;
}
@@ -822,8 +866,14 @@ static bool gtk_graph_display_move_caret_to(GtkGraphDisplay *display, gint x, gi
static GLineCursor *gtk_graph_display_get_cursor(const GtkGraphDisplay *display)
{
GLineCursor *result; /* Contenu à retourner */
+ GtkWidget *child; /* Composant sélectionné */
+
+ child = gtk_container_get_focus_child(GTK_CONTAINER(display->support));
- result = NULL;
+ if (child != NULL)
+ result = g_loaded_panel_get_cursor(G_LOADED_PANEL(child));
+ else
+ result = NULL;
return result;
@@ -1012,7 +1062,7 @@ static void gtk_graph_display_reset(GtkGraphDisplay *display, bool dispose)
if (display->highlighted != NULL)
{
- exit_segment_content_list(display->highlighted);
+ unref_segment_content_list(display->highlighted);
display->highlighted = NULL;
}