diff options
Diffstat (limited to 'src/gtkext')
-rw-r--r-- | src/gtkext/Makefile.am | 18 | ||||
-rw-r--r-- | src/gtkext/blockbar.ui | 97 | ||||
-rw-r--r-- | src/gtkext/gresource.xml | 6 | ||||
-rw-r--r-- | src/gtkext/gtkblockdisplay.c | 2 | ||||
-rw-r--r-- | src/gtkext/gtkbufferdisplay-int.h | 3 | ||||
-rw-r--r-- | src/gtkext/gtkbufferdisplay.c | 156 | ||||
-rw-r--r-- | src/gtkext/gtkbufferdisplay.h | 8 | ||||
-rw-r--r-- | src/gtkext/gtkdisplaypanel-int.h | 4 | ||||
-rw-r--r-- | src/gtkext/gtkdisplaypanel.c | 4 |
9 files changed, 294 insertions, 4 deletions
diff --git a/src/gtkext/Makefile.am b/src/gtkext/Makefile.am index 158e591..24df0c3 100644 --- a/src/gtkext/Makefile.am +++ b/src/gtkext/Makefile.am @@ -1,6 +1,11 @@ +BUILT_SOURCES = resources.h resources.c + noinst_LTLIBRARIES = libgtkext.la +UI_FILES = \ + blockbar.ui + libgtkext_la_SOURCES = \ diagram.h diagram.c \ easygtk.h easygtk.c \ @@ -16,6 +21,7 @@ libgtkext_la_SOURCES = \ gtkgraphdisplay.h gtkgraphdisplay.c \ gtkstatusstack.h gtkstatusstack.c \ rendering.h rendering.c \ + resources.h resources.c \ support.h support.c \ tiledgrid.h tiledgrid.c \ tmgt.h tmgt.c @@ -36,3 +42,15 @@ AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) SUBDIRS = graph + + +resources.c: gresource.xml $(UI_FILES) + glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name gtkext gresource.xml + +resources.h: gresource.xml + glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name gtkext gresource.xml + + +CLEANFILES = resources.h resources.c + +EXTRA_DIST = gresource.xml $(UI_FILES) diff --git a/src/gtkext/blockbar.ui b/src/gtkext/blockbar.ui new file mode 100644 index 0000000..b8f07cd --- /dev/null +++ b/src/gtkext/blockbar.ui @@ -0,0 +1,97 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.21.0 --> +<interface> + <requires lib="gtk+" version="3.20"/> + <object class="GtkOffscreenWindow"> + <property name="can_focus">False</property> + <child> + <object class="GtkGrid" id="blockbar"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkButton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="focus_on_click">False</property> + <property name="receives_default">True</property> + <property name="tooltip_text" translatable="yes">Define a background color for the whole block</property> + <property name="opacity">0.59999999999999998</property> + <property name="relief">none</property> + <signal name="enter-notify-event" handler="on_block_bar_enter_notify" swapped="no"/> + <signal name="leave-notify-event" handler="on_block_bar_leave_notify" swapped="no"/> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="can_focus">False</property> + </object> + </child> + <style> + <class name="tinybutton"/> + <class name="block-palette"/> + </style> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkButton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="focus_on_click">False</property> + <property name="receives_default">True</property> + <property name="tooltip_text" translatable="yes">Collapse the block with all its dominated blocks</property> + <property name="opacity">0.59999999999999998</property> + <property name="relief">none</property> + <signal name="enter-notify-event" handler="on_block_bar_enter_notify" swapped="no"/> + <signal name="leave-notify-event" handler="on_block_bar_leave_notify" swapped="no"/> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="can_focus">False</property> + </object> + </child> + <style> + <class name="tinybutton"/> + <class name="block-collapse"/> + </style> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkButton"> + <property name="can_focus">True</property> + <property name="focus_on_click">False</property> + <property name="receives_default">True</property> + <property name="tooltip_text" translatable="yes">Expand the collapses block</property> + <property name="opacity">0.59999999999999998</property> + <property name="relief">none</property> + <signal name="enter-notify-event" handler="on_block_bar_enter_notify" swapped="no"/> + <signal name="leave-notify-event" handler="on_block_bar_leave_notify" swapped="no"/> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="can_focus">False</property> + </object> + </child> + <style> + <class name="tinybutton"/> + <class name="block-expand"/> + </style> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">0</property> + </packing> + </child> + </object> + </child> + <child type="titlebar"> + <placeholder/> + </child> + </object> +</interface> diff --git a/src/gtkext/gresource.xml b/src/gtkext/gresource.xml new file mode 100644 index 0000000..0250484 --- /dev/null +++ b/src/gtkext/gresource.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<gresources> + <gresource prefix="/org/chrysalide/gtkext"> + <file compressed="true">blockbar.ui</file> + </gresource> +</gresources> diff --git a/src/gtkext/gtkblockdisplay.c b/src/gtkext/gtkblockdisplay.c index 97136c9..546c1aa 100644 --- a/src/gtkext/gtkblockdisplay.c +++ b/src/gtkext/gtkblockdisplay.c @@ -429,4 +429,6 @@ void gtk_block_display_override_view_index(GtkBlockDisplay *display, unsigned in GTK_BUFFER_DISPLAY(display)->offsets.max_widths[BLC_ASSEMBLY_LABEL] = 0; + gtk_buffer_display_add_block_bar(GTK_BUFFER_DISPLAY(display)); + } diff --git a/src/gtkext/gtkbufferdisplay-int.h b/src/gtkext/gtkbufferdisplay-int.h index c84f6d5..b4b64d0 100644 --- a/src/gtkext/gtkbufferdisplay-int.h +++ b/src/gtkext/gtkbufferdisplay-int.h @@ -49,6 +49,9 @@ struct _GtkBufferDisplay guint caret_timer; /* Identifiant du chronomètre */ bool show_caret; /* Bascule entre les affichages*/ + GtkBuilder *builder; /* Constructeur à manipuler */ + GtkWidget *bar; /* Barre d'outils intégrée */ + }; /* Composant d'affichage de tampon de lignes (classe) */ 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; + +} diff --git a/src/gtkext/gtkbufferdisplay.h b/src/gtkext/gtkbufferdisplay.h index 73fbbde..6c6c8b5 100644 --- a/src/gtkext/gtkbufferdisplay.h +++ b/src/gtkext/gtkbufferdisplay.h @@ -67,4 +67,12 @@ bool gtk_buffer_display_move_caret_to(GtkBufferDisplay *, bool, gint *); +/* ------------------------- INCLUSION D'UNE BARRE D'OUTILS ------------------------- */ + + +/* Ajoute une nouvelle barre d'outils pour bloc au composant. */ +void gtk_buffer_display_add_block_bar(GtkBufferDisplay *); + + + #endif /* _GTKEXT_GTKBUFFER_DISPLAY_H */ diff --git a/src/gtkext/gtkdisplaypanel-int.h b/src/gtkext/gtkdisplaypanel-int.h index 7d64925..62c990e 100644 --- a/src/gtkext/gtkdisplaypanel-int.h +++ b/src/gtkext/gtkdisplaypanel-int.h @@ -37,6 +37,10 @@ +/* Amplitude de l'arrondi pour les coins */ +#define BORDER_CORNER_RADIUS 10.0 + + /* Indique les dimensions de travail du composant d'affichage. */ typedef void (* compute_requested_size_fc) (GtkDisplayPanel *, gint *, gint *); diff --git a/src/gtkext/gtkdisplaypanel.c b/src/gtkext/gtkdisplaypanel.c index e548bf7..010d648 100644 --- a/src/gtkext/gtkdisplaypanel.c +++ b/src/gtkext/gtkdisplaypanel.c @@ -33,10 +33,6 @@ -/* Amplitude de l'arrondi pour les coins */ -#define BORDER_CORNER_RADIUS 10.0 - - /* Procède à l'initialisation de l'afficheur générique. */ static void gtk_display_panel_class_init(GtkDisplayPanelClass *); |