diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-06-05 17:00:13 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-06-05 17:00:13 +0200 |
commit | 79aa24abaed9794a5402ecf44ef98860c013c8a0 (patch) | |
tree | 3c85414ab49de611f712883b7ea318d76bd9f67c /lib/gtk-experiment-widgets/gtk-experiment-transcript.c | |
parent | a1d9f08c714bf4f3c9a51909cf3c0f242cbb3450 (diff) | |
download | experiment-player-79aa24abaed9794a5402ecf44ef98860c013c8a0.tar.gz |
fixed transcript widget configuration (on Windows)
* widget configuration in size allocation depends on widget being realized
* widget realization depends on the widget being size allocated
* at least on Windows, the size is not reallocated after widget
realization (except of course it is actually resized)
* so a _reconfigure() function has been introduced (does the same as configure-event handler would do)
Diffstat (limited to 'lib/gtk-experiment-widgets/gtk-experiment-transcript.c')
-rw-r--r-- | lib/gtk-experiment-widgets/gtk-experiment-transcript.c | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/lib/gtk-experiment-widgets/gtk-experiment-transcript.c b/lib/gtk-experiment-widgets/gtk-experiment-transcript.c index 7fddc99..9df5bb9 100644 --- a/lib/gtk-experiment-widgets/gtk-experiment-transcript.c +++ b/lib/gtk-experiment-widgets/gtk-experiment-transcript.c @@ -36,6 +36,8 @@ static void gtk_experiment_transcript_finalize(GObject *gobject); static void time_adj_on_value_changed(GtkAdjustment *adj, gpointer user_data); +static void gtk_experiment_transcript_reconfigure(GtkExperimentTranscript *trans); + static void state_changed(GtkWidget *widget, GtkStateType state); static gboolean button_pressed(GtkWidget *widget, GdkEventButton *event); static gboolean scrolled(GtkWidget *widget, GdkEventScroll *event); @@ -248,6 +250,8 @@ gtk_experiment_transcript_realize(GtkWidget *widget) gdk_window_set_user_data(widget->window, widget); gtk_style_set_background(widget->style, widget->window, GTK_STATE_ACTIVE); + + gtk_experiment_transcript_reconfigure(GTK_EXPERIMENT_TRANSCRIPT(widget)); } static void @@ -266,30 +270,16 @@ gtk_experiment_transcript_size_allocate(GtkWidget *widget, gboolean sizeChanged = widget->allocation.width != allocation->width || widget->allocation.height != allocation->height; - widget->allocation = *allocation; - - if (!gtk_widget_get_realized(widget)) - return; - - gdk_window_move_resize(gtk_widget_get_window(widget), - allocation->x, allocation->y, - allocation->width, allocation->height); - - if (!sizeChanged) - return; + gtk_widget_set_allocation(widget, allocation); - gtk_adjustment_set_page_size(GTK_ADJUSTMENT(trans->priv->time_adjustment), - (gdouble)PX_TO_TIME(allocation->height)); + if (gtk_widget_get_realized(widget)) { + gdk_window_move_resize(gtk_widget_get_window(widget), + allocation->x, allocation->y, + allocation->width, allocation->height); - GOBJECT_UNREF_SAFE(trans->priv->layer_text); - trans->priv->layer_text = gdk_pixmap_new(gtk_widget_get_window(widget), - allocation->width, - allocation->height + LAYER_TEXT_INVISIBLE, - -1); - pango_layout_set_width(trans->priv->layer_text_layout, - allocation->width*PANGO_SCALE); - - gtk_experiment_transcript_text_layer_redraw(trans); + if (sizeChanged || trans->priv->layer_text == NULL) + gtk_experiment_transcript_reconfigure(trans); + } } static gboolean @@ -320,6 +310,25 @@ time_adj_on_value_changed(GtkAdjustment *adj, gpointer user_data) gtk_experiment_transcript_text_layer_redraw(trans); } +static void +gtk_experiment_transcript_reconfigure(GtkExperimentTranscript *trans) +{ + GtkWidget *widget = GTK_WIDGET(trans); + + gtk_adjustment_set_page_size(GTK_ADJUSTMENT(trans->priv->time_adjustment), + (gdouble)PX_TO_TIME(widget->allocation.height)); + + GOBJECT_UNREF_SAFE(trans->priv->layer_text); + trans->priv->layer_text = gdk_pixmap_new(gtk_widget_get_window(widget), + widget->allocation.width, + widget->allocation.height + LAYER_TEXT_INVISIBLE, + -1); + pango_layout_set_width(trans->priv->layer_text_layout, + widget->allocation.width*PANGO_SCALE); + + gtk_experiment_transcript_text_layer_redraw(trans); +} + /** @private */ void gtk_experiment_transcript_text_layer_redraw(GtkExperimentTranscript *trans) |