Commit 42eab88e authored by Cheng Sun's avatar Cheng Sun Committed by Jean-Baptiste Kempf

Add popup_menu to VlcPlugin interface; minor cleanups

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent bef62b7d
......@@ -285,6 +285,7 @@ public:
virtual bool destroy_windows() = 0;
virtual void update_controls() = 0;
virtual void popup_menu() = 0;
static bool canUseEventListener();
......
......@@ -12,8 +12,7 @@ VlcPluginGtk::VlcPluginGtk(NPP instance, NPuint16_t mode) :
parent(NULL),
parent_vbox(NULL),
video(NULL),
toolbar(NULL),
popup_menu(NULL)
toolbar(NULL)
{
}
......@@ -99,20 +98,10 @@ static void menu_handler(GtkMenuItem *menuitem, gpointer user_data)
fprintf(stderr, "WARNING: No idea what menu item you just clicked on (%s)\n", stock_id?stock_id:"NULL");
}
void VlcPluginGtk::do_popup_menu(GtkWidget *widget, GdkEventButton *event)
void VlcPluginGtk::popup_menu()
{
int button, event_time;
if (event) {
button = event->button;
event_time = event->time;
} else {
button = 0;
event_time = gtk_get_current_event_time();
}
/* construct menu */
GtkWidget *popup_menu = gtk_menu_new();
GtkWidget *popupmenu = gtk_menu_new();
GtkWidget *menuitem;
/* play/pause */
......@@ -121,25 +110,24 @@ void VlcPluginGtk::do_popup_menu(GtkWidget *widget, GdkEventButton *event)
GTK_STOCK_MEDIA_PAUSE :
GTK_STOCK_MEDIA_PLAY, NULL);
g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(menu_handler), this);
gtk_menu_shell_append(GTK_MENU_SHELL(popup_menu), menuitem);
gtk_menu_shell_append(GTK_MENU_SHELL(popupmenu), menuitem);
/* stop */
menuitem = gtk_image_menu_item_new_from_stock(
GTK_STOCK_MEDIA_STOP, NULL);
g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(menu_handler), this);
gtk_menu_shell_append(GTK_MENU_SHELL(popup_menu), menuitem);
gtk_widget_show_all(popup_menu);
gtk_menu_shell_append(GTK_MENU_SHELL(popupmenu), menuitem);
gtk_menu_attach_to_widget(GTK_MENU(popup_menu), widget, NULL);
gtk_menu_popup(GTK_MENU(popup_menu), NULL, NULL, NULL, NULL,
button, event_time);
gtk_widget_show_all(popupmenu);
gtk_menu_attach_to_widget(GTK_MENU(popupmenu), video, NULL);
gtk_menu_popup(GTK_MENU(popupmenu), NULL, NULL, NULL, NULL,
0, gtk_get_current_event_time());
}
static bool video_button_handler(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
{
VlcPluginGtk *plugin = (VlcPluginGtk *) user_data;
if (event->button == 3 && event->type == GDK_BUTTON_PRESS) {
plugin->do_popup_menu(widget, event);
plugin->popup_menu();
return true;
}
return false;
......@@ -147,7 +135,7 @@ static bool video_button_handler(GtkWidget *widget, GdkEventButton *event, gpoin
static bool video_popup_handler(GtkWidget *widget, gpointer user_data) {
VlcPluginGtk *plugin = (VlcPluginGtk *) user_data;
plugin->do_popup_menu(widget, NULL);
plugin->popup_menu();
return true;
}
......
......@@ -49,15 +49,15 @@ public:
void show_toolbar();
void hide_toolbar();
void update_controls();
void do_popup_menu(GtkWidget *,GdkEventButton *);
void popup_menu();
private:
void set_player_window();
unsigned int i_width, i_height;
GtkWidget *parent, *parent_vbox, *video;
GtkWidget *toolbar, *popup_menu, *time_slider;
GtkWidget *toolbar, *time_slider;
};
#endif /* __VLCPLUGIN_GTK_H__ */
......@@ -34,21 +34,6 @@ int VlcPluginMac::get_fullscreen()
return r;
}
void VlcPluginMac::show_toolbar()
{
// TODO
}
void VlcPluginMac::hide_toolbar()
{
// TODO
}
void VlcPluginMac::update_controls()
{
// TODO
}
bool VlcPluginMac::create_windows()
{
return true;
......
......@@ -47,10 +47,10 @@ public:
bool resize_windows();
bool destroy_windows();
void show_toolbar();
void hide_toolbar();
void update_controls();
void show_toolbar() {/* STUB */};
void hide_toolbar() {/* STUB */};
void update_controls() {/* STUB */};
void popup_menu() {/* STUB */};
private:
void set_player_window();
......
......@@ -55,6 +55,7 @@ public:
void hide_toolbar();
void update_controls();
void popup_menu();
WNDPROC getWindowProc()
{ return pf_wndproc; };
......
......@@ -43,21 +43,6 @@ int VlcPluginXlib::get_fullscreen()
return r;
}
void VlcPluginXlib::show_toolbar()
{
/* TODO */
}
void VlcPluginXlib::hide_toolbar()
{
/* TODO */
}
void VlcPluginXlib::update_controls()
{
/* TODO */
}
bool VlcPluginXlib::create_windows()
{
......
......@@ -47,9 +47,10 @@ public:
bool resize_windows();
bool destroy_windows();
void show_toolbar();
void hide_toolbar();
void update_controls();
void show_toolbar() {/* STUB */};
void hide_toolbar() {/* STUB */};
void update_controls() {/* STUB */};
void popup_menu() {/* STUB */};
Display *getDisplay();
private:
......
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