After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 138365 - Gtk::Action::get_[menu|tool]_item should return Gtk::[Menu|Tool]Item*
Gtk::Action::get_[menu|tool]_item should return Gtk::[Menu|Tool]Item*
Status: RESOLVED FIXED
Product: gtkmm
Classification: Bindings
Component: general
2.4
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2004-03-28 22:54 UTC by Bryan Forbes
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to fix this (3.04 KB, patch)
2004-03-28 22:55 UTC, Bryan Forbes
none Details | Review

Description Bryan Forbes 2004-03-28 22:54:39 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);
}
Comment 1 Bryan Forbes 2004-03-28 22:55:41 UTC
Created attachment 26034 [details] [review]
Patch to fix this
Comment 2 Murray Cumming 2004-03-29 10:18:55 UTC
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.