Commit 86ecac3f authored by Sergey Radionov's avatar Sergey Radionov Committed by Jean-Baptiste Kempf

ActiveX, npapi: privatize vlc_player_option

Use it like a VlcPlugin/VlcPluginBase member.
Adapted-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent fed577d6
......@@ -215,7 +215,7 @@ STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErr
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("FullscreenEnabled"), &value, pErrorLog) )
{
_p_instance->set_enable_fs(V_BOOL(&value) != VARIANT_FALSE);
_p_instance->get_options().set_enable_fs(V_BOOL(&value) != VARIANT_FALSE);
VariantClear(&value);
}
......@@ -286,7 +286,7 @@ STDMETHODIMP VLCPersistPropertyBag::Save(LPPROPERTYBAG pPropBag, BOOL fClearDirt
VariantClear(&value);
V_VT(&value) = VT_BOOL;
V_BOOL(&value) = _p_instance->get_enable_fs()? VARIANT_TRUE : VARIANT_FALSE;
V_BOOL(&value) = _p_instance->get_options().get_enable_fs()? VARIANT_TRUE : VARIANT_FALSE;
pPropBag->Write(OLESTR("FullscreenEnabled"), &value);
VariantClear(&value);
......
......@@ -75,7 +75,7 @@ private:
LPPICTURE _inplace_picture;
};
struct VLCPlugin : public IUnknown, public vlc_player_options
struct VLCPlugin : public IUnknown, private vlc_player_options
{
public:
VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter);
......@@ -90,6 +90,11 @@ public:
REFCLSID getClassID(void) { return _p_class->getClassID(); };
REFIID getDispEventID(void) { return (REFIID)DIID_DVLCEvents; };
vlc_player_options& get_options()
{ return *static_cast<vlc_player_options*>(this); }
const vlc_player_options& get_options() const
{ return *static_cast<const vlc_player_options*>(this); }
/*
** persistant properties
*/
......
......@@ -1476,14 +1476,14 @@ STDMETHODIMP VLCControl2::get_FullscreenEnabled(VARIANT_BOOL* enabled)
if( NULL == enabled )
return E_POINTER;
*enabled = varbool( _p_instance->get_enable_fs() );
*enabled = varbool( _p_instance->get_options().get_enable_fs() );
return S_OK;
}
STDMETHODIMP VLCControl2::put_FullscreenEnabled(VARIANT_BOOL enabled)
{
_p_instance->set_enable_fs( VARIANT_FALSE != enabled );
_p_instance->get_options().set_enable_fs( VARIANT_FALSE != enabled );
return S_OK;
}
......
......@@ -190,7 +190,7 @@ typedef enum vlc_toolbar_clicked_e {
clicked_Unmute
} vlc_toolbar_clicked_t;
class VlcPluginBase: public vlc_player_options
class VlcPluginBase: private vlc_player_options
{
protected:
......@@ -198,6 +198,11 @@ public:
VlcPluginBase( NPP, NPuint16_t );
virtual ~VlcPluginBase();
vlc_player_options& get_options()
{ return *static_cast<vlc_player_options*>(this); }
const vlc_player_options& get_options() const
{ return *static_cast<const vlc_player_options*>(this); }
NPError init(int argc, char* const argn[], char* const argv[]);
libvlc_instance_t* getVLC()
{ return libvlc_instance; };
......
......@@ -108,7 +108,7 @@ void VlcPluginGtk::do_set_fullscreen(bool yes)
void VlcPluginGtk::set_fullscreen(int yes)
{
if (!get_enable_fs()) return;
if (!get_options().get_enable_fs()) return;
if (yes == is_fullscreen) return;
if (yes) {
gtk_widget_show(fullscreen_win);
......@@ -217,7 +217,7 @@ void VlcPluginGtk::popup_menu()
g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(menu_handler), this);
gtk_menu_shell_append(GTK_MENU_SHELL(popupmenu), menuitem);
/* set fullscreen */
if (get_enable_fs()) {
if (get_options().get_enable_fs()) {
menuitem = gtk_image_menu_item_new_from_stock(
GTK_STOCK_FULLSCREEN, NULL);
g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(menu_handler), this);
......@@ -414,7 +414,7 @@ bool VlcPluginGtk::create_windows()
Window socket = (Window) npwindow.window;
GdkColor color_bg;
gdk_color_parse(get_bg_color().c_str(), &color_bg);
gdk_color_parse(get_options().get_bg_color().c_str(), &color_bg);
parent = gtk_plug_new(socket);
gtk_widget_modify_bg(parent, GTK_STATE_NORMAL, &color_bg);
......
......@@ -42,14 +42,14 @@ void VlcPluginMac::set_player_window()
void VlcPluginMac::toggle_fullscreen()
{
if (!get_enable_fs()) return;
if (!get_options().get_enable_fs()) return;
if (playlist_isplaying())
libvlc_toggle_fullscreen(libvlc_media_player);
}
void VlcPluginMac::set_fullscreen(int yes)
{
if (!get_enable_fs()) return;
if (!get_options().get_enable_fs()) return;
if (playlist_isplaying())
libvlc_set_fullscreen(libvlc_media_player, yes);
}
......
......@@ -88,7 +88,7 @@ LRESULT CALLBACK VlcPluginWin::NPWndProcR(HWND hWnd, UINT uMsg, WPARAM wParam, L
VlcPluginWin::VlcPluginWin(NPP instance, NPuint16_t mode) :
VlcPluginBase(instance, mode), _NPWndProc(0),
_WindowsManager(DllGetModule(), _ViewRC, this)
_WindowsManager(DllGetModule(), _ViewRC, &get_options())
{
_ViewRC.hDeFullscreenBitmap =
LoadImage(DllGetModule(), MAKEINTRESOURCE(3),
......
......@@ -48,14 +48,14 @@ void VlcPluginXcb::set_player_window()
void VlcPluginXcb::toggle_fullscreen()
{
if (!get_enable_fs()) return;
if (!get_options().get_enable_fs()) return;
if (playlist_isplaying())
libvlc_toggle_fullscreen(libvlc_media_player);
}
void VlcPluginXcb::set_fullscreen(int yes)
{
if (!get_enable_fs()) return;
if (!get_options().get_enable_fs()) return;
if (playlist_isplaying())
libvlc_set_fullscreen(libvlc_media_player,yes);
}
......@@ -96,7 +96,7 @@ bool VlcPluginXcb::create_windows()
colormap = screen->default_colormap;
unsigned r = 0, g = 0, b = 0;
HTMLColor2RGB(get_bg_color().c_str(), &r, &g, &b);
HTMLColor2RGB(get_options().get_bg_color().c_str(), &r, &g, &b);
xcb_alloc_color_reply_t *reply = xcb_alloc_color_reply(conn,
xcb_alloc_color(conn, colormap,
(uint16_t) r << 8,
......
......@@ -350,7 +350,8 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
p_plugin->resize_windows();
/* now set plugin state to that requested in parameters */
p_plugin->set_toolbar_visible( p_plugin->get_show_toolbar() );
bool show_toolbar = p_plugin->get_options().get_show_toolbar();
p_plugin->set_toolbar_visible( show_toolbar );
/* handle streams properly */
if( !p_plugin->b_stream )
......@@ -359,7 +360,7 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
{
if( p_plugin->playlist_add( p_plugin->psz_target ) != -1 )
{
if( p_plugin->get_autoplay() )
if( p_plugin->get_options().get_autoplay() )
{
p_plugin->playlist_play();
}
......@@ -461,7 +462,7 @@ void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* )
if( p_plugin->playlist_add( stream->url ) != -1 )
{
if( p_plugin->get_autoplay() )
if( p_plugin->get_options().get_autoplay() )
{
p_plugin->playlist_play();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment