📄 hxstatuspositionslider.cpp
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: hxstatuspositionslider.cpp,v 1.12.2.5 2004/07/09 01:48:55 hubbe Exp $ * * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. * * The contents of this file, and the files included with this file, * are subject to the current version of the RealNetworks Public * Source License (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the current version of the RealNetworks Community * Source License (the "RCSL") available at * http://www.helixcommunity.org/content/rcsl, in which case the RCSL * will apply. You may also obtain the license terms directly from * RealNetworks. You may not use this file except in compliance with * the RPSL or, if you have a valid RCSL with RealNetworks applicable * to this file, the RCSL. Please see the applicable RPSL or RCSL for * the rights, obligations and limitations governing use of the * contents of the file. * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL") in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your version of * this file only under the terms of the GPL, and not to allow others * to use your version of this file under the terms of either the RPSL * or RCSL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient may * use your version of this file under the terms of any one of the * RPSL, the RCSL or the GPL. * * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the * portions it created. * * This file, and the files included with this file, is distributed * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET * ENJOYMENT OR NON-INFRINGEMENT. * * Technology Compatibility Kit Test Suite(s) Location: * http://www.helixcommunity.org/content/tck * * Contributor(s): * * ***** END LICENSE BLOCK ***** */#include "hxstatuspositionslider.h"#include "hxplayer.h"#ifdef HELIX_FEATURE_EMBEDDED_PLAYER#include "embeddedapp.h"#endif#include <stdio.h>#include "hxplayer-i18n.h"#include "playeripc.h"// RGG - stop the timer when we're hiddenextern "C"{static void hsdp_play(HXStatusDisplayPositionSlider* position_status);static void hsdp_pause(HXStatusDisplayPositionSlider* position_status);static void hsdp_stop(HXStatusDisplayPositionSlider* position_status);static void hsdp_seek(HXStatusDisplayPositionSlider* status, guint pos);static void hsdp_length_changed(HXStatusDisplayPositionSlider* status, guint len);static gboolean hsdp_button_press(HXStatusDisplayPositionSlider* position_status, GdkEvent *event);static gboolean hsdp_button_release(HXStatusDisplayPositionSlider* position_status, GdkEvent *event);static void hsdp_event_after(HXStatusDisplayPositionSlider* position_status, GdkEvent *event);static void hsdp_value_changed(HXStatusDisplayPositionSlider* position_status); };static void hxstatus_display_position_slider_class_init (HXStatusDisplayPositionSliderClass* klass);static void hxstatus_display_position_slider_init (HXStatusDisplayPositionSlider* status, HXStatusDisplayPositionSliderClass* klass);static void hxstatus_display_position_slider_set_player (HXStatusDisplay* status, HXPlayer* player);static HXStatusDisplayClass* g_parent_class = NULL;GTypehxstatus_display_position_slider_get_type (void){ static GType hxstatus_display_position_slider_type = 0; if (!hxstatus_display_position_slider_type) { static const GTypeInfo hxstatus_display_position_slider_info = { sizeof (HXStatusDisplayPositionSliderClass), NULL, /* base_init */ NULL, /* base_finalize */ (GClassInitFunc) hxstatus_display_position_slider_class_init, NULL, /* class_finalize */ NULL, /* class_data */ sizeof (HXStatusDisplayPositionSlider), 0, /* n_preallocs */ (GInstanceInitFunc) hxstatus_display_position_slider_init, NULL, /* value_table */ }; hxstatus_display_position_slider_type = g_type_register_static (HX_TYPE_STATUS_DISPLAY, "HXStatusDisplayPositionSlider", &hxstatus_display_position_slider_info, (GTypeFlags)0); } return hxstatus_display_position_slider_type;}GtkWidget*hxstatus_display_position_slider_new(void){ HXStatusDisplayPositionSlider* status = (HXStatusDisplayPositionSlider*)g_object_new(HX_TYPE_STATUS_DISPLAY_POSITION_SLIDER, NULL); GtkWidget* hscale; hscale = gtk_hscale_new_with_range(0.0, 1.0, 1.0); gtk_scale_set_draw_value(GTK_SCALE(hscale), FALSE); g_signal_connect_swapped(G_OBJECT(hscale), "button_press_event", G_CALLBACK(hsdp_button_press), status); g_signal_connect_swapped(G_OBJECT(hscale), "button_release_event", G_CALLBACK(hsdp_button_release), status); /* We want to seek after the hscale's button_release_event is done. */ g_signal_connect_swapped(G_OBJECT(hscale), "event-after", G_CALLBACK(hsdp_event_after), status); g_signal_connect_swapped(G_OBJECT(hscale), "value-changed", G_CALLBACK(hsdp_value_changed), status); status->position_scale = hscale; status->player_signal_handlers_array = g_array_new (FALSE, FALSE, sizeof (gint)); gtk_container_add(GTK_CONTAINER(status), hscale); gtk_widget_show(hscale); return GTK_WIDGET(status);}#ifdef HELIX_FEATURE_EMBEDDED_PLAYERGtkWidget*hxstatus_display_position_slider_new_with_embedded_window(HXEmbeddedWindow* window){ GtkWidget* widget; HXStatusDisplayPositionSlider* status; widget = hxstatus_display_position_slider_new(); status = HX_STATUS_DISPLAY_POSITION_SLIDER(widget); status->embedded_window = window; return widget;}#endifstatic guinthxstatus_display_position_slider_get_update_interval(HXStatusDisplayPositionSlider* position_status){ guint interval = 0; guint clip_length; guint pixel_length; const guint min_update_interval = 200; // in ms HXStatusDisplay* status; status = HX_STATUS_DISPLAY(position_status); if(!status->player) { return min_update_interval; } pixel_length = GTK_WIDGET(position_status->position_scale)->allocation.width; clip_length = hx_player_get_length(status->player); if(pixel_length > 0) { interval = clip_length / pixel_length; } if(interval < min_update_interval) { interval = min_update_interval; } return interval;}/* A callback to gtk_timeout_add() */static gbooleanhxstatus_display_position_slider_update(gpointer user_data){ guint pos; guint len; HXStatusDisplayPositionSlider* position_status = HX_STATUS_DISPLAY_POSITION_SLIDER(user_data); HXStatusDisplay* status = HX_STATUS_DISPLAY(user_data); g_return_val_if_fail(position_status->position_scale != NULL, TRUE); if(status->player) { pos = hx_player_get_position(HX_PLAYER(status->player)); len = hx_player_get_length(HX_PLAYER(status->player)); if(len > 0) { gtk_range_set_value(GTK_RANGE(position_status->position_scale), (gdouble)pos); gtk_range_set_range(GTK_RANGE(position_status->position_scale), 0, (gdouble)len); } } return TRUE; // don't remove}static voidhxstatus_display_position_slider_init(HXStatusDisplayPositionSlider* status, HXStatusDisplayPositionSliderClass* /* klass */){ status->position_scale = NULL; status->embedded_window = NULL; status->button_1_is_pressed = FALSE; status->seek_started = FALSE; status->player_signal_handlers_array = NULL; status->player_signal_handlers_array_len = 0;}static voidhxstatus_display_position_slider_class_init (HXStatusDisplayPositionSliderClass* klass){ HXStatusDisplayClass* status_class = HX_STATUS_DISPLAY_CLASS(klass); g_parent_class = (HXStatusDisplayClass*)gtk_type_class(HX_TYPE_STATUS_DISPLAY); status_class->set_player = hxstatus_display_position_slider_set_player;}static voidhxstatus_display_position_slider_seek_start(HXStatusDisplayPositionSlider* position_status){ HXStatusDisplay* status; status = HX_STATUS_DISPLAY(position_status); hxstatus_display_stop_timer(status); if(position_status->embedded_window) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -