From 78ab2d265d8fbd2bb4bbfb1533645154e12db2c2 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Thu, 14 Jun 2012 14:30:27 +0200 Subject: new navigator signal (for Jens to use): section-selected should be emitted when an entry is single-clicked * connected with transcript widgets: the selected section becomes the transcripts backdrop area * updated documentation for callbacks in class structure --- .../cclosure-marshallers.list | 3 ++ .../gtk-experiment-navigator.c | 46 ++++++++++++++++++++-- .../gtk-experiment-navigator.h | 16 ++++++-- 3 files changed, 59 insertions(+), 6 deletions(-) (limited to 'lib/gtk-experiment-widgets') diff --git a/lib/gtk-experiment-widgets/cclosure-marshallers.list b/lib/gtk-experiment-widgets/cclosure-marshallers.list index c3ecc04..539e1a4 100644 --- a/lib/gtk-experiment-widgets/cclosure-marshallers.list +++ b/lib/gtk-experiment-widgets/cclosure-marshallers.list @@ -1,2 +1,5 @@ # Standard marshallers for "time-selected" signal callbacks VOID:INT64 + +# Standard marshallers for "section-activated" signal callbacks +VOID:INT64,INT64 diff --git a/lib/gtk-experiment-widgets/gtk-experiment-navigator.c b/lib/gtk-experiment-widgets/gtk-experiment-navigator.c index 2d1c48a..52143ad 100644 --- a/lib/gtk-experiment-widgets/gtk-experiment-navigator.c +++ b/lib/gtk-experiment-widgets/gtk-experiment-navigator.c @@ -48,7 +48,10 @@ static void time_cell_data_cb(GtkTreeViewColumn *col, gpointer user_data); -static inline void select_time(GtkExperimentNavigator *navi, gint64 selected_time); +static inline void select_time(GtkExperimentNavigator *navi, + gint64 selected_time); +static inline void activate_section(GtkExperimentNavigator *navi, + gint64 start, gint64 end); /** * @private @@ -89,6 +92,7 @@ struct _GtkExperimentNavigatorPrivate { /** @private */ enum { TIME_SELECTED_SIGNAL, + SECTION_ACTIVATED_SIGNAL, LAST_SIGNAL }; static guint gtk_experiment_navigator_signals[LAST_SIGNAL] = {0}; @@ -117,10 +121,20 @@ static void gtk_experiment_navigator_class_init(GtkExperimentNavigatorClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); + GtkTreeViewClass *treeview_class = GTK_TREE_VIEW_CLASS(klass); gobject_class->dispose = gtk_experiment_navigator_dispose; gobject_class->finalize = gtk_experiment_navigator_finalize; + /** + * @todo + * Set signal handlers to respond to row selection (double-click) and + * row activations (single-click) in order to emit the "time-selected" + * and "section-activated" signals on the navigator widget. + * To set a signal handler simply set the \e GtkTreeView's + * class structure fields. + */ + gtk_experiment_navigator_signals[TIME_SELECTED_SIGNAL] = g_signal_new("time-selected", G_TYPE_FROM_CLASS(klass), @@ -130,6 +144,15 @@ gtk_experiment_navigator_class_init(GtkExperimentNavigatorClass *klass) gtk_experiment_widgets_marshal_VOID__INT64, G_TYPE_NONE, 1, G_TYPE_INT64); + gtk_experiment_navigator_signals[SECTION_ACTIVATED_SIGNAL] = + g_signal_new("section-activated", + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET(GtkExperimentNavigatorClass, section_activated), + NULL, NULL, + gtk_experiment_widgets_marshal_VOID__INT64_INT64, + G_TYPE_NONE, 2, G_TYPE_INT64, G_TYPE_INT64); + g_type_class_add_private(klass, sizeof(GtkExperimentNavigatorPrivate)); } @@ -216,7 +239,6 @@ gtk_experiment_navigator_init(GtkExperimentNavigator *klass) g_object_unref(store); /** @todo better \e TreeViewColumn formatting */ - /** @todo connect signals to respond to row activations */ /** * @todo * Initialize necessary \b public and \b private attributes. @@ -328,7 +350,7 @@ time_cell_data_cb(GtkTreeViewColumn *col __attribute__((unused)), /** * @brief Emit "time-selected" signal on a \e GtkExperimentNavigator instance. * - * It should be emitted when a row entry was selected. + * It should be emitted when a row entry was selected (double-clicked). * * @sa GtkExperimentNavigatorClass::time_selected * @@ -342,6 +364,24 @@ select_time(GtkExperimentNavigator *navi, gint64 selected_time) selected_time); } +/** + * @brief Emit "section-activated" signal on a \e GtkExperimentNavigator instance. + * + * It should be emitted when a row entry was activated (e.g. single-clicked) + * + * @sa GtkExperimentNavigatorClass::section_activated + * + * @param navi Widget to emit the signal on + * @param start Start time of section in milliseconds + * @param end End time of section in milliseconds + */ +static inline void +activate_section(GtkExperimentNavigator *navi, gint64 start, gint64 end) +{ + g_signal_emit(navi, gtk_experiment_navigator_signals[SECTION_ACTIVATED_SIGNAL], 0, + start, end); +} + /* * API */ diff --git a/lib/gtk-experiment-widgets/gtk-experiment-navigator.h b/lib/gtk-experiment-widgets/gtk-experiment-navigator.h index 0a0e73e..af0ae50 100644 --- a/lib/gtk-experiment-widgets/gtk-experiment-navigator.h +++ b/lib/gtk-experiment-widgets/gtk-experiment-navigator.h @@ -76,14 +76,24 @@ typedef struct _GtkExperimentNavigatorClass { /** * Callback function to invoke when emitting the "time-selected" - * signal. Do not set manually. + * signal. * * @param self \e GtkExperimentNavigator the event was emitted on. * @param selected_time Time selected by the navigator in milliseconds - * @param user_data Callback user data */ void (*time_selected)(GtkExperimentNavigator *self, - gint64 selected_time, gpointer user_data); + gint64 selected_time); + + /** + * Callback function to invoke when emitting the "section-activated" + * signal. + * + * @param self \e GtkExperimentNavigator the event was emitted on. + * @param start Start time of section in milliseconds + * @param end End time of section in milliseconds + */ + void (*section_activated)(GtkExperimentNavigator *self, + gint64 start, gint64 end); } GtkExperimentNavigatorClass; /** @private */ -- cgit v1.2.3