GNOME Bugzilla – Bug 138365
Gtk::Action::get_[menu|tool]_item should return Gtk::[Menu|Tool]Item*
Last modified: 2004-12-22 21:47:04 UTC
Instead of making the developer do the casting, we should do this. Also, the C calls to these functions return the correct type: static GtkWidget * create_menu_item (GtkAction *action) { GType menu_item_type; // this type ends up being GTK_TYPE_IMAGE_MENU_ITEM menu_item_type = GTK_ACTION_GET_CLASS (action)->menu_item_type; return g_object_new (menu_item_type, NULL); } static GtkWidget * create_tool_item (GtkAction *action) { GType toolbar_item_type; // this type ends up being GTK_TYPE_TOOL_BUTTON toolbar_item_type = GTK_ACTION_GET_CLASS (action)->toolbar_item_type; return g_object_new (toolbar_item_type, NULL); }
Created attachment 26034 [details] [review] Patch to fix this
Applied. Thanks. I did the same for get_icon(), and I removed the unnecesasry Gtk:: namespace prefixes from the return types. There is a small risk that these do not always return these types - because you just have to derive an action with a menu_item_type of GTK_TYPE_SOMETHING_DIFFERENT to break this, but I guess the intention is just to have different sub-types. But we've taken this risk before.