Re: [Mplayerplug-in-devel] Question about how to diff, Idea for features and a bug report
Brought to you by:
kdekorte
From: Anders L. <li...@io...> - 2005-10-24 17:10:09
|
Hi again Okay then - your the boss :), we'll do it that way (ofcause the code could be changed, but it is fine with me that we e.g. wait till X is skipped in this project and gtk1 is abandoned by mozilla or just let it be as it is. Here is the raw code for the button handling for gtk 2 and the icons in xpm are attached. I diff later - if needed by you - so you can see the code now. ---Top of plugin-ui.cpp--- #include "../pixmaps/menu_down_small.xpm" #include "../pixmaps/menu_up_small.xpm" ---In method InitPixbufs---: instance->pb_sm_menu_up = gdk_pixbuf_new_from_xpm_data((const char **) menu_up_small); instance->pb_sm_menu_down = gdk_pixbuf_new_from_xpm_data((const char **) menu_down_small); ---New methods placed after the other callbacks such as keyboard_callback and mouse_callback - these new methods is by the way the ones I thought of placing in a dedicated class to handle all the buttons along with other gui related code ---: #ifdef GTK2_ENABLED /* control focus of menu */ static gboolean menu_has_focus = FALSE; static gboolean menu_button_pressed = FALSE; static gboolean menu_button_down (nsPluginInstance * instance, gboolean down) { if (instance->panel_height > 16) instance->panel_height = 16; gtk_container_remove(GTK_CONTAINER(instance->menu_event_box), instance->image_menu); //#ifdef GTK2_ENABLED if(down == true) instance->image_menu = gtk_image_new_from_pixbuf(instance->pb_sm_menu_down); else instance->image_menu = gtk_image_new_from_pixbuf(instance->pb_sm_menu_up); //#endif //#ifdef GTK1_ENABLED //instance->image_menu = // gtk_pixmap_new(instance->pb_sm_menu_down, NULL); //#endif gtk_container_add(GTK_CONTAINER(instance->menu_event_box), instance->image_menu); if (instance->showbuttons) { gtk_widget_show(instance->image_menu); gtk_widget_show(instance->menu_event_box); } gtk_widget_show(instance->fixed_container); gdk_flush(); return TRUE; } gboolean menu_released_callback( GtkWidget * widget, GdkEvent * event, nsPluginInstance * instance) { if (instance == NULL) return FALSE; if (event->type == GDK_BUTTON_RELEASE) { menu_button_pressed = FALSE; if(menu_has_focus == TRUE) { GdkEventButton *bevent = (GdkEventButton *) event; gtk_menu_popup (GTK_MENU (instance->popup_menu), NULL, NULL, NULL, NULL, bevent->button, bevent->time); /* Tell calling code that we have handled this event; the buck * stops here. */ } return TRUE; } /* Tell calling code that we have not handled this event; pass it on. */ return FALSE; } gboolean menu_pressed_callback( GtkWidget * widget, GdkEvent * event, nsPluginInstance * instance) { if (instance == NULL) return FALSE; if (event->type == GDK_BUTTON_PRESS && menu_has_focus == TRUE) { if (instance->controlsvisible == 1) { menu_button_pressed = TRUE; menu_button_down(instance, TRUE); } return TRUE; } return FALSE; } gboolean menu_enter_callback( GtkWidget * widget, GdkEvent * event, nsPluginInstance * instance) { if (instance == NULL) return FALSE; if (event->type == GDK_ENTER_NOTIFY) { if (instance->controlsvisible == 1) { menu_has_focus = TRUE; /* if we regain focus while button is pressed - redraw to get attetion */ if(menu_button_pressed == TRUE) menu_button_down(instance, TRUE); } return TRUE; } return FALSE; } gboolean menu_leave_callback( GtkWidget * widget, GdkEvent * event, nsPluginInstance * instance) { if (instance == NULL) return FALSE; if (event->type == GDK_LEAVE_NOTIFY) { menu_has_focus = FALSE; menu_button_down(instance, FALSE); return TRUE; } return FALSE; } #endif ---In gtkgui_draw in the first #ifdef GTK2_ENABLED section insert this just before fullscreen (instance->image_fs) for instance ---: instance->image_menu = gtk_image_new_from_pixbuf(instance->pb_sm_menu_up); ---In gtkgui_draw --- insert this chunk of code just before fullscreen as I think it would be placed fine there---: #ifdef GTK2_ENABLED // menu instance->menu_event_box = gtk_event_box_new(); gtk_widget_set_events(instance->menu_event_box, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); g_signal_connect (G_OBJECT(instance->menu_event_box), "button_release_event", G_CALLBACK(menu_released_callback), instance); g_signal_connect (G_OBJECT(instance->menu_event_box), "button_press_event", G_CALLBACK(menu_pressed_callback), instance); g_signal_connect (G_OBJECT(instance->menu_event_box), "enter_notify_event", G_CALLBACK(menu_enter_callback), instance); g_signal_connect (G_OBJECT(instance->menu_event_box), "leave_notify_event", G_CALLBACK(menu_leave_callback), instance); gtk_container_add(GTK_CONTAINER(instance->menu_event_box), instance->image_menu); if (win_width > 147) { /*IS THIS MAGIC NUMBER CORRECT NOW???????????????????????????? GUESS IT IS buttonwidth times buttons = 21 * 6 + 21 * 1 (for the menubutton) so the size should be changed to 147 instead of 126 */ gtk_fixed_put(GTK_FIXED(instance->fixed_container), instance->menu_event_box, win_width - width*2, win_height - height); if (instance->showbuttons) { gtk_widget_show(instance->image_menu); gtk_widget_show(instance->menu_event_box); } } #endif --- Then something is missing in gtkgui_updatebuttons (and some of the other methods in the plugin.cpp) however not needed now just to test --- --- In plugin.h in the #ifdef GTK_ENABLED section of class nsPluginInstance:public nsPluginInstanceBase insert where it should resign --- : GtkWidget *menu_event_box; ---and---: GtkWidget *image_menu; --- and in the #ifdef GTK2_ENABLED part of the class ---: GdkPixbuf *pb_sm_menu_up; GdkPixbuf *pb_sm_menu_down; --- In plugin.cpp in the class implementation of nsPluginInstance, nsPluginInstance::nsPluginInstance(NPP aInstance):nsPluginInstanceBase(), mInstance(aInstance), mInitialized(FALSE), mScriptablePeer(NULL), mControlsScriptablePeer(NULL), insert in #ifdef GTK_ENABLED section ---: menu_event_box = NULL; --- In void nsPluginInstance::shutdown() insert in the #ifdef GTK_ENABLED section among the rest of the eventboxes the same line as above ---: menu_event_box = NULL; --- in plugin-setup.h I'm not sure whether it is necessary to have the callbacks I've made as prototypes - well you decide :) ---: And that should be it to test how it works. So please do :) Well, my most wanted feature (beside getting the mplayer team to fix the bug about the MBR mms streams) would be a volume slider, and I found some examples. So beside my first proposal: http://www.truelaunchbar.com/plugins/volctl.php http://www.shelltoys.com/volume_control/screenshots1.html http://officeone.mvps.org/volctrl/volctrl_screenshots.html , something like these would be nice. the one from shelltoys are groovy :) but less can do it as well. What is important is that the control is small and smaller than the default gtk one. So I'll look into it and make it go for the simplistic version of a volume slider button like ------|-- - we can always make it look different. I just saw you mail about the tooltips went in - I look at it and see how it looks as the cvs version is coming in from sourceforge. Kind regards Anders man, 24 10 2005 kl. 09:37 -0600, skrev Kevin DeKorte: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Show me the code.... > > Also you might want to prepare a diff against current CVS as I have been > busy with the GUI. I had to mess with a few things to get the Apple HD > stuff to work better. > > Personally I don't think the button code is really that bad. I'm sure it > could use some improvements, but it could be a lot worse. > > I'm am not planning on switching to GTK_BUTTONs as the current > GTK_EVENT_BOXes give some flexibility that you cannot really do with > buttons. > > I believe for the tooltips the only events you would need would be the > enter and leave events > > But this may be even easier (I've been saving this info for awhile if I > were to implement tooltips) > > http://www.gtk.org/tutorial/sec-thetooltipsobject.html > > GtkTooltips *tooltips; > GtkWidget *button; > tooltips = gtk_tooltips_new (); > button = gtk_button_new_with_label ("button 1"); > gtk_tooltips_set_tip (tooltips, button, "This is button 1", NULL); > > So you should just have to hook up the tooltip to the button and be done > with it.. > > Here are the docs on the tooltips > > http://www.gtk.org/api/2.6/gtk/GtkTooltips.html > > I'm sure I could put this in the code in about 5 mins... so if you want > me to do that, that is ok with me. > > I'm still not sure about a "menu" button, right click is pretty common > and is "docuumented" on the screen shots page. I'd rather have a volume > button and since we are cramped on space, volume would be accepted quicker. > > Kevin > > Anders Lind wrote: > > Hi Kevin and all of you > > > > You probably wonder why you havent heard from me yet :) > > > > Well, I made the button, and the code for putting the button on the > > screen, when it e.g. is resized to full screen, has to be set some > > places in the code. The last thing I havent made yet, but tried it out > > some time ago. > > > > However after I started to make some code and I could soon see, that > > what I wanted was normal button behaviour for the menu button. So I used > > some time to figure out the right events that should trigger button up > > and down etc. (gtk isn't that good documented after my point of view ;)) > > So I use GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | > > GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK and some methods and 2 > > variables for handling button up and down and whether the mouse is in > > focus over the button. > > > > Now I'm quite convinced that this feature would be nice to have on the > > other buttons so I'm starting to make some generic class for the button > > methods that handle button up and down and what is related to setting up > > the button in the panel - cause I think the code is a mess all the > > places where the image has to be loaded, disabled and the like. > > > > So, if you are not going to change to gtk alone in the near future - and > > therefore consider only to use ordinary gtk button - but still use gtk > > event boxes I'll continue my work. > > > > My intention is, that it should be really more easy to handle the button > > events than it is today where you have to fiddle with the code so many > > places so it is possible to write the necessary code only once and make > > it easier to NOT lose oneself in details when just placing a single new > > button or getting the unstable states that we discussed to many times - > > well probably it will not solve everything but it will tidy it up i > > hope. I hope you like if I comment the code! > > > > I'm ready to do that job allthough it'll take some time to finish. But > > in the end it is my wish that the irritating GUI problems will vanish > > because the responsibility for common features is placed in a common > > class(es). > > > > Sorry for the long post. > > > > Hope it is something you will endorse. > > > > > > Regards > > > > Anders > > > > PS As to my other wishes in my last post - well when they irritate me > > too much I'll make a patch :) > > > > søn, 09 10 2005 kl. 15:35 -0600, skrev Kevin DeKorte: > > > >>On Saturday 08 October 2005 10:01 am, Anders Lind wrote: > >> > >>>1. I've made a patch for mplayerplug-in so when a menu button is pressed > >>>the menu is shown at the position of where the mouse is. In that way the > >>>user is knowing that there is a menu! > >>> > >>>- For now I've only made it for GTK2, which makes it useless for GTK1 > >>>users. So I need to do some testing on GTK1 - also to see whether I > >>>havent made a bug between the the 2 versions of GTK. > >>>Do I need to install the old netscape 4.79 for getting an environment > >>>with GTK1 and does it use GTK1? > >> > >>Send it in, GTK2 is definitely where all the good stuff is going. But GTK1 > >>will be around until mozilla quits shipping that way. I downloaded it > >>recently and that is what I use to test GTK1 code. > >> > >> > >>>- Will GTK1 be supported forever or will it be removed in the near > >>>future? > >> > >>I'd love to remove GTK1 and X, but so far I can't. X mode gives a warning when > >>you configure it that way. > >> > >> > >>>- What is your prefered options for diff when I post the patch for the 2 > >>>or 3 files I have altered? > >>> > >> > >>Diff against CVS with the -u option is ok. But diffing against the last > >>release is ok too. > >> > >> > >>>2. I thought about adding a tool tip for the buttons like described on > >>>http://gtk.org/tutorial/x831.html > >>> > >>>The tool tip for the buttons could tell the user of: > >>>Name of function eg.: Play > >>>Shortcut key eg.: P > >>> > >>>Eg. like: "Play media - <P>" > >>>or "Play - P" > >>> > >>>For people knowing the functions (eg fast forward) or bothered of the > >>>tooltips one could make an option in the Configuration window to > >>>enable/disable this feature! > >>> > >> > >>Well I've tried to make the controls look like the controls on a tape > >>recorder, so I'm not sure why someone would not know them. But I'll take a > >>patch. > >> > >> > >>>It is also posssible to set a delay before the tooltip is shown with > >>>gtk_tooltips_set_delay > >>> > >>>Finally see my example in the bottom of my mail. > >>> > >>>3. I made some concept art for a volume slider that is 2 times a buttons > >>>width. The dimensions and the look may ofcause change, but it is more to > >>>get an idea to how it works and the way it signals the current audio > >>>level. > >>> > >>>- What do you think of the idea? > >>> > >>>- Does anyone know of a library where custom made gtk widgets are > >>>located on the net - I would really like to see some examples? > >>> > >>>Else I guess I have to use the gtkDialPad example for studying (from > >>>gtk.org) if no custom made widget is ready or easy to alter. > >>> > >>> > >> > >>Volume has been asked about before, mainly since I always use the master > >>volume it has not been a high priority for me personally. So that is why I > >>have not coded it up. > >> > >>I was thinking about a tooltip-ish type of dialog that came up that has a left > >>right slider it in, that you used to control the volume. The semantics of how > >>it would work I have not figured out, and so I have not done it. > >> > >> > >> > >>>If possible please take a look at winamp 5.1 for windows and see the > >>>fullscreen view for video media. > >>>I like how the fullscreen icon is placed in the top of the screen and > >>>how the controls are made as well as the progress/seeking slider. Notice > >>>also that the controls are shown when you move the mouse. > >>> > >> > >>Probably not going to happen, since the full screen and small screen code for > >>positioning the buttons share the same code path. I find it usable, and so > >>there is not a real good reason to change. > >> > >> > >>>- Would it be something we would like to see in mplayerplug-in? > >>> (It would take some effort to make it look like that! I'm not sure > >>>whether I've got the time or that skilled to do that. But nice though.) > >>> > >>> > >>> > >>>4. Bug > >>>When mplayerplug-in starts to play a media then if you disable "Show > >>>Controls" from the menu the buttons flash once, but are afterwards still > >>>shown - however without working. > >>>(Enabling the control buttons again make them work properly.) > >>> > >> > >>Yup, your right it does that... I might take a look at it. > >> > >> > >>>5. I'm also (still) planning to make a patch/workarround for the bad > >>>sound and videoquality issue because of the mplayer bug when mplayer > >>>handles MS's mms multibitrate streams, however I see that a method > >>>mmsToHttp already exists in plugin-support.cpp but it is however not > >>>used by mplayerplug-in when I seek through the files of the project. > >>> > >>>An option in the configuration window to enable renaming of mms streams > >>>to http would be nice, so when mplayer finally gets the URL of the > >>>stream (after it has been parsed by mplayerplug-in) it has already been > >>>replaced with http by mplayerplug-in. That would be really nice. > >>> > >> > >>So what happens in the case where the URL says to use an MMS and you change it > >>to an HTTP and the site returns a 404? What do you do then? > >> > >> > >>>Kind regards > >>> > >>>Anders Lind > >>> > >> > >>Interesting comments Anders... I'll accept and maybe merge in patches. I'm > >>trying to minimize the amount of changes that go in to ensure that the code > >>is stable. That last push kinda burned me out on the code for awhile. > >> > >>Kevin > >> > > > > > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by the JBoss Inc. > > Get Certified Today * Register for a JBoss Training Course > > Free Certification Exam for All Training Attendees Through End of 2005 > > Visit http://www.jboss.com/services/certification for more information > > _______________________________________________ > > Mplayerplug-in-devel mailing list > > Mpl...@li... > > https://lists.sourceforge.net/lists/listinfo/mplayerplug-in-devel > > > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.1 (GNU/Linux) > > iD8DBQFDXP/NaR60qN0tF+8RAiwqAJ9Z4AQWNcYporuDas9intWhoTmEgACg1Lxg > 6GCYeBLlw9WW5h0rK/+0OZo= > =r8XT > -----END PGP SIGNATURE----- > > > ------------------------------------------------------- > This SF.Net email is sponsored by the JBoss Inc. > Get Certified Today * Register for a JBoss Training Course > Free Certification Exam for All Training Attendees Through End of 2005 > Visit http://www.jboss.com/services/certification for more information > _______________________________________________ > Mplayerplug-in-devel mailing list > Mpl...@li... > https://lists.sourceforge.net/lists/listinfo/mplayerplug-in-devel > |