[vlc-commits] Add popup_menu to VlcPlugin interface; minor cleanups
Cheng Sun
git at videolan.org
Wed Dec 21 12:54:09 CET 2011
npapi-vlc | branch: master | Cheng Sun <chengsun9 at gmail.com> | Sat Dec 10 14:55:44 2011 +0000| [42eab88e817d280e6839e764b1f7af5359a548a5] | committer: Jean-Baptiste Kempf
Add popup_menu to VlcPlugin interface; minor cleanups
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/npapi-vlc.git/?a=commit;h=42eab88e817d280e6839e764b1f7af5359a548a5
---
npapi/vlcplugin_base.h | 1 +
npapi/vlcplugin_gtk.cpp | 34 +++++++++++-----------------------
npapi/vlcplugin_gtk.h | 6 +++---
npapi/vlcplugin_mac.cpp | 15 ---------------
npapi/vlcplugin_mac.h | 8 ++++----
npapi/vlcplugin_win.h | 1 +
npapi/vlcplugin_xlib.cpp | 15 ---------------
npapi/vlcplugin_xlib.h | 7 ++++---
8 files changed, 24 insertions(+), 63 deletions(-)
diff --git a/npapi/vlcplugin_base.h b/npapi/vlcplugin_base.h
index a675815..20ce444 100644
--- a/npapi/vlcplugin_base.h
+++ b/npapi/vlcplugin_base.h
@@ -285,6 +285,7 @@ public:
virtual bool destroy_windows() = 0;
virtual void update_controls() = 0;
+ virtual void popup_menu() = 0;
static bool canUseEventListener();
diff --git a/npapi/vlcplugin_gtk.cpp b/npapi/vlcplugin_gtk.cpp
index a64b732..fc4ef01 100644
--- a/npapi/vlcplugin_gtk.cpp
+++ b/npapi/vlcplugin_gtk.cpp
@@ -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;
}
diff --git a/npapi/vlcplugin_gtk.h b/npapi/vlcplugin_gtk.h
index 69340d6..9891809 100644
--- a/npapi/vlcplugin_gtk.h
+++ b/npapi/vlcplugin_gtk.h
@@ -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__ */
diff --git a/npapi/vlcplugin_mac.cpp b/npapi/vlcplugin_mac.cpp
index b219a50..3ca889c 100644
--- a/npapi/vlcplugin_mac.cpp
+++ b/npapi/vlcplugin_mac.cpp
@@ -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;
diff --git a/npapi/vlcplugin_mac.h b/npapi/vlcplugin_mac.h
index 5a458f6..6dace61 100644
--- a/npapi/vlcplugin_mac.h
+++ b/npapi/vlcplugin_mac.h
@@ -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();
diff --git a/npapi/vlcplugin_win.h b/npapi/vlcplugin_win.h
index 4a2bf6e..5fccd38 100644
--- a/npapi/vlcplugin_win.h
+++ b/npapi/vlcplugin_win.h
@@ -55,6 +55,7 @@ public:
void hide_toolbar();
void update_controls();
+ void popup_menu();
WNDPROC getWindowProc()
{ return pf_wndproc; };
diff --git a/npapi/vlcplugin_xlib.cpp b/npapi/vlcplugin_xlib.cpp
index 0df54f7..b3886b8 100644
--- a/npapi/vlcplugin_xlib.cpp
+++ b/npapi/vlcplugin_xlib.cpp
@@ -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()
{
diff --git a/npapi/vlcplugin_xlib.h b/npapi/vlcplugin_xlib.h
index 3b40050..69fe03b 100644
--- a/npapi/vlcplugin_xlib.h
+++ b/npapi/vlcplugin_xlib.h
@@ -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:
More information about the vlc-commits
mailing list