summaryrefslogtreecommitdiff
path: root/src/gtkext/gtkbufferdisplay.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-01-23 20:16:14 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-01-23 20:16:14 (GMT)
commitd0a287a4e57b299cec22c94b028e3553d5b36fcd (patch)
tree86a274d6c894ec6506f0b5d55436d958a556f9fc /src/gtkext/gtkbufferdisplay.c
parentf251814cf0fd10a767972530c119f8f109613c48 (diff)
Prepared a toolbar for actions on basic blocks.
Diffstat (limited to 'src/gtkext/gtkbufferdisplay.c')
-rw-r--r--src/gtkext/gtkbufferdisplay.c156
1 files changed, 156 insertions, 0 deletions
diff --git a/src/gtkext/gtkbufferdisplay.c b/src/gtkext/gtkbufferdisplay.c
index 1b452f1..5ad808f 100644
--- a/src/gtkext/gtkbufferdisplay.c
+++ b/src/gtkext/gtkbufferdisplay.c
@@ -108,6 +108,20 @@ static void gtk_buffer_display_draw_caret(GtkBufferDisplay *, cairo_t *);
+/* ------------------------- INCLUSION D'UNE BARRE D'OUTILS ------------------------- */
+
+
+/* Place correctement la barre d'outils pour bloc. */
+static void gtk_buffer_display_move_block_bar(GtkBufferDisplay *);
+
+/* Accompagne le début du survol d'un élément de barre d'outils. */
+static gboolean on_block_bar_enter_notify(GtkWidget *, GdkEventCrossing *, GtkBufferDisplay *);
+
+/* Accompagne la fin du survol d'un élément de barre d'outils. */
+static gboolean on_block_bar_leave_notify(GtkWidget *, GdkEventCrossing *, GtkBufferDisplay *);
+
+
+
/* ---------------------------------------------------------------------------------- */
/* INTERACTION DIRECTE AVEC GTK */
/* ---------------------------------------------------------------------------------- */
@@ -223,6 +237,9 @@ static void gtk_buffer_display_dispose(GtkBufferDisplay *display)
g_clear_object(&display->cursor);
+ g_clear_object(&display->builder);
+ g_clear_object(&display->bar);
+
G_OBJECT_CLASS(gtk_buffer_display_parent_class)->dispose(G_OBJECT(display));
}
@@ -466,6 +483,10 @@ static gboolean gtk_buffer_display_draw(GtkWidget *widget, cairo_t *cr)
cairo_restore(cr);
+ /* Dessin des composants contenus */
+
+ GTK_WIDGET_CLASS(gtk_buffer_display_parent_class)->draw(widget, cr);
+
return FALSE;
}
@@ -565,10 +586,22 @@ static gboolean gtk_buffer_display_key_press(GtkWidget *widget, GdkEventKey *eve
static void gtk_buffer_display_compute_requested_size(GtkBufferDisplay *display, gint *width, gint *height)
{
+ gint extra; /* Eventuel supplément largeur */
+
if (width != NULL)
{
if (display->view != NULL)
+ {
*width = g_buffer_view_get_width(display->view, GTK_DISPLAY_PANEL(display)->options);
+
+ if (display->bar != NULL)
+ {
+ gtk_widget_get_preferred_width(display->bar, NULL, &extra);
+ *width += extra;
+ }
+
+ }
+
else
*width = 0;
}
@@ -1183,3 +1216,126 @@ static void gtk_buffer_display_draw_caret(GtkBufferDisplay *display, cairo_t *cr
}
}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* INCLUSION D'UNE BARRE D'OUTILS */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : display = panneau d'affichage concerné. *
+* *
+* Description : Ajoute une nouvelle barre d'outils pour bloc au composant. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void gtk_buffer_display_add_block_bar(GtkBufferDisplay *display)
+{
+ GtkWidget *bar; /* Barre d'outils à intégrer */
+
+ assert(display->builder == NULL);
+
+ display->builder = gtk_builder_new_from_resource("/org/chrysalide/gtkext/blockbar.ui");
+
+ bar = GTK_WIDGET(gtk_builder_get_object(display->builder, "blockbar"));
+
+ display->bar = bar;
+ g_object_ref(G_OBJECT(bar));
+
+ g_object_ref(G_OBJECT(bar));
+ gtk_widget_unparent(bar);
+
+ gtk_fixed_put(GTK_FIXED(display), bar, 0, 0);
+
+ gtk_builder_add_callback_symbols(display->builder,
+ "on_block_bar_enter_notify", G_CALLBACK(on_block_bar_enter_notify),
+ "on_block_bar_leave_notify", G_CALLBACK(on_block_bar_leave_notify),
+ NULL);
+
+ gtk_builder_connect_signals(display->builder, display);
+
+ gtk_buffer_display_move_block_bar(display);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : display = panneau d'affichage concerné. *
+* *
+* Description : Place correctement la barre d'outils pour bloc. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_buffer_display_move_block_bar(GtkBufferDisplay *display)
+{
+ GtkWidget *bar; /* Barre d'outils courante */
+ gint width; /* Largeur requise à vide */
+
+ bar = display->bar;
+ display->bar = NULL;
+
+ gtk_buffer_display_compute_requested_size(display, &width, NULL);
+
+ display->bar = bar;
+
+ gtk_fixed_move(GTK_FIXED(display), bar, width, (int)BORDER_CORNER_RADIUS / 2);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : widget = composant graphique concerné par l'opération. *
+* event = informations liées à l'événement. *
+* display = panneau d'affichage impliqué par l'action. *
+* *
+* Description : Accompagne le début du survol d'un élément de barre d'outils.*
+* *
+* Retour : FALSE pour poursuivre la propagation de l'événement. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static gboolean on_block_bar_enter_notify(GtkWidget *widget, GdkEventCrossing *event, GtkBufferDisplay *display)
+{
+ gtk_widget_set_opacity(widget, 1.0);
+
+ return FALSE;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : widget = composant graphique concerné par l'opération. *
+* event = informations liées à l'événement. *
+* display = panneau d'affichage impliqué par l'action. *
+* *
+* Description : Accompagne la fin du survol d'un élément de barre d'outils. *
+* *
+* Retour : FALSE pour poursuivre la propagation de l'événement. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static gboolean on_block_bar_leave_notify(GtkWidget *widget, GdkEventCrossing *event, GtkBufferDisplay *display)
+{
+ gtk_widget_set_opacity(widget, 0.6);
+
+ return FALSE;
+
+}