Hello Bastiaan,
Thank you for your advices.
2006-11-09 (木) の 12:59 +0100 に Bastiaan Jacques さんは書きました:
> In general, I like your patch. You haven't added icons to all menu
> items; can you find suitable icons for the missing ones too?
I have nerver been found other suitable icons. I hope someone create new
nice icons.
> Instead of defining each menu item twice, I think it would be easier to
> read this way:
>
> GtkMenuItem *menuitem_play =
> GTK_MENU_ITEM(gtk_menu_item_new_with_label("Play Movie"));
> ...
>
> #if GTK_CHECK_VERSION(2,6,0)
> GtkWidget *play_image =
> GTK_WIDGET(gtk_image_new_from_stock(GTK_STOCK_REFRESH,
> GTK_ICON_SIZE_MENU));
> gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(menuitem_play),
> play_image);
> ...
> #endif
>
> So that's like your implementation for menuitem_restart, for all menu
> items.
Actually, GTK+ can't to do such thing because GtkImageMenuItem is a sub
object of GtkMenuItem.
gtk_image_menu_new_from_stock() do gtk_image_menu_item_new_with_label()
and gtk_image_menu_set_image() with label and image owned by GTK+
itself, and moreover, the label is gettextized. That is very important
for non-English users like me.
The reason why I do not use gtk_image_menu_new_from_stock() for "Restart
Movie" menu is that the label of GTK_STOCK_REFRESH is "Refresh". It is
not suitable for I think.
> > + // Menu for sound
> > if (get_sound_handler()) {
> > + GtkMenuItem *menuitem_sound =
> > + GTK_MENU_ITEM(gtk_check_menu_item_new_with_label("Toggle
> > Sound")); gtk_menu_append(_popup_menu, GTK_WIDGET(menuitem_sound));
> > + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem_sound),
> > + get_sound_handler()->is_muted() ?
>
> You call get_sound_handler() twice; you should store the return value of
> this function to a temporary pointer to use in your call to
> gtk_check_menu_item_set_active().
Yes, you are right. It is redundant.
I've fixed it in a new patch attaching in this mail.
Thank you,
Hiroyuki Ikezoe
Index: gui/gtk.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gtk.cpp,v
retrieving revision 1.47
diff -d -u -p -r1.47 gtk.cpp
--- gui/gtk.cpp 5 Nov 2006 23:10:43 -0000 1.47
+++ gui/gtk.cpp 10 Nov 2006 00:19:10 -0000
@@ -280,47 +280,76 @@ GtkGui::createMenu()
_popup_menu = GTK_MENU(gtk_menu_new());
+#if GTK_CHECK_VERSION(2,6,0)
+ GtkMenuItem *menuitem_play =
+ GTK_MENU_ITEM(gtk_image_menu_item_new_from_stock(GTK_STOCK_MEDIA_PLAY, NULL));
+ GtkMenuItem *menuitem_pause =
+ GTK_MENU_ITEM(gtk_image_menu_item_new_from_stock(GTK_STOCK_MEDIA_PAUSE, NULL));
+ GtkMenuItem *menuitem_stop =
+ GTK_MENU_ITEM(gtk_image_menu_item_new_from_stock(GTK_STOCK_MEDIA_STOP, NULL));
+ GtkMenuItem *menuitem_restart =
+ GTK_MENU_ITEM(gtk_image_menu_item_new_with_label("Restart Movie"));
+ GtkWidget *restart_image =
+ GTK_WIDGET(gtk_image_new_from_stock(GTK_STOCK_REFRESH, GTK_ICON_SIZE_MENU));
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(menuitem_restart), restart_image);
+ GtkMenuItem *menuitem_step_forward =
+ GTK_MENU_ITEM(gtk_menu_item_new_with_label("Step Forward Frame"));
+ GtkMenuItem *menuitem_step_backward =
+ GTK_MENU_ITEM(gtk_menu_item_new_with_label("Step Backward Frame"));
+ GtkMenuItem *menuitem_jump_forward =
+ GTK_MENU_ITEM(gtk_menu_item_new_with_label("Jump Forward 10 Frames"));
+ GtkMenuItem *menuitem_jump_backward =
+ GTK_MENU_ITEM(gtk_menu_item_new_with_label("Jump Backward 10 Frames"));
+#else /* GTK_CHECK_VERSION(2,6,0) */
GtkMenuItem *menuitem_play =
GTK_MENU_ITEM(gtk_menu_item_new_with_label("Play Movie"));
- gtk_menu_append(_popup_menu, GTK_WIDGET(menuitem_play));
- gtk_widget_show(GTK_WIDGET(menuitem_play));
GtkMenuItem *menuitem_pause =
GTK_MENU_ITEM(gtk_menu_item_new_with_label("Pause Movie"));
- gtk_menu_append(_popup_menu, GTK_WIDGET(menuitem_pause));
- gtk_widget_show(GTK_WIDGET(menuitem_pause));
GtkMenuItem *menuitem_stop =
GTK_MENU_ITEM(gtk_menu_item_new_with_label("Stop Movie"));
- gtk_menu_append(_popup_menu, GTK_WIDGET(menuitem_stop));
- gtk_widget_show(GTK_WIDGET(menuitem_stop));
GtkMenuItem *menuitem_restart =
GTK_MENU_ITEM(gtk_menu_item_new_with_label("Restart Movie"));
- gtk_menu_append(_popup_menu, GTK_WIDGET(menuitem_restart));
- gtk_widget_show(GTK_WIDGET(menuitem_restart));
GtkMenuItem *menuitem_step_forward =
GTK_MENU_ITEM(gtk_menu_item_new_with_label("Step Forward Frame"));
- gtk_menu_append(_popup_menu, GTK_WIDGET(menuitem_step_forward));
- gtk_widget_show(GTK_WIDGET(menuitem_step_forward));
GtkMenuItem *menuitem_step_backward =
GTK_MENU_ITEM(gtk_menu_item_new_with_label("Step Backward Frame"));
- gtk_menu_append(_popup_menu, GTK_WIDGET(menuitem_step_backward));
- gtk_widget_show(GTK_WIDGET(menuitem_step_backward));
GtkMenuItem *menuitem_jump_forward =
GTK_MENU_ITEM(gtk_menu_item_new_with_label("Jump Forward 10 Frames"));
- gtk_menu_append(_popup_menu, GTK_WIDGET(menuitem_jump_forward));
- gtk_widget_show(GTK_WIDGET(menuitem_jump_forward));
GtkMenuItem *menuitem_jump_backward =
GTK_MENU_ITEM(gtk_menu_item_new_with_label("Jump Backward 10 Frames"));
+#endif
+ gtk_menu_append(_popup_menu, GTK_WIDGET(menuitem_play));
+ gtk_widget_show(GTK_WIDGET(menuitem_play));
+ gtk_menu_append(_popup_menu, GTK_WIDGET(menuitem_pause));
+ gtk_widget_show(GTK_WIDGET(menuitem_pause));
+ gtk_menu_append(_popup_menu, GTK_WIDGET(menuitem_stop));
+ gtk_widget_show(GTK_WIDGET(menuitem_stop));
+ gtk_menu_append(_popup_menu, GTK_WIDGET(menuitem_restart));
+ gtk_widget_show(GTK_WIDGET(menuitem_restart));
+ gtk_menu_append(_popup_menu, GTK_WIDGET(menuitem_step_forward));
+ gtk_widget_show(GTK_WIDGET(menuitem_step_forward));
+ gtk_menu_append(_popup_menu, GTK_WIDGET(menuitem_step_backward));
+ gtk_widget_show(GTK_WIDGET(menuitem_step_backward));
+ gtk_menu_append(_popup_menu, GTK_WIDGET(menuitem_jump_forward));
+ gtk_widget_show(GTK_WIDGET(menuitem_jump_forward));
gtk_menu_append(_popup_menu, GTK_WIDGET(menuitem_jump_backward));
gtk_widget_show(GTK_WIDGET(menuitem_jump_backward));
- GtkMenuItem *menuitem_sound =
- GTK_MENU_ITEM(gtk_menu_item_new_with_label("Toggle Sound"));
- if (get_sound_handler()) {
+
+ // Menu for sound
+ sound_handler *snd_handler = get_sound_handler ();
+ if (snd_handler) {
+ GtkMenuItem *menuitem_sound =
+ GTK_MENU_ITEM(gtk_check_menu_item_new_with_label("Toggle Sound"));
gtk_menu_append(_popup_menu, GTK_WIDGET(menuitem_sound));
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem_sound),
+ snd_handler->is_muted() ? FALSE : TRUE);
gtk_widget_show(GTK_WIDGET(menuitem_sound));
+ g_signal_connect(GTK_OBJECT(menuitem_sound), "activate",
+ G_CALLBACK(&menuitem_sound_callback), this);
}
GtkMenuItem *menuitem_quit =
- GTK_MENU_ITEM(gtk_menu_item_new_with_label("Quit Gnash"));
+ GTK_MENU_ITEM(gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL));
gtk_menu_append(_popup_menu, GTK_WIDGET(menuitem_quit));
gtk_widget_show(GTK_WIDGET(menuitem_quit));
g_signal_connect(GTK_OBJECT(menuitem_play), "activate",
@@ -341,10 +370,6 @@ GtkGui::createMenu()
G_CALLBACK(&menuitem_jump_backward_callback), this);
g_signal_connect(GTK_OBJECT(menuitem_quit), "activate",
G_CALLBACK(&menuitem_quit_callback), this);
- if (get_sound_handler()) {
- g_signal_connect(GTK_OBJECT(menuitem_sound), "activate",
- G_CALLBACK(&menuitem_sound_callback), this);
- }
return true;
}
_______________________________________________
Gnash-dev mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnash-dev