From bcd804c6c383e2964b072257da282d9a91db7d16 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Thu, 5 Apr 2012 22:14:44 +0200 Subject: C++ify context menu: - c++ified context-menu.cpp (and included in interface.cpp) - removed dozens of pointer conversions (of which some were erroneous) - fixed a memory leak - added some null pointer checks to prevent crashes (bzr r11160) --- src/event-context.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/event-context.cpp') diff --git a/src/event-context.cpp b/src/event-context.cpp index 0cfa18f57..4ea4068fe 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -6,8 +6,9 @@ * Frank Felfe * bulia byak * Jon A. Cruz + * Kris De Gussem * - * Copyright (C) 1999-2010 authors + * Copyright (C) 1999-2012 authors * Copyright (C) 2001-2002 Ximian, Inc. * * Released under GNU GPL, read the file 'COPYING' for more information @@ -1034,22 +1035,19 @@ static void set_event_location(SPDesktop *desktop, GdkEvent *event) { * Create popup menu and tell Gtk to show it. */ void sp_event_root_menu_popup(SPDesktop *desktop, SPItem *item, GdkEvent *event) { - GtkWidget *menu; - /* fixme: This is not what I want but works for now (Lauris) */ if (event->type == GDK_KEY_PRESS) { item = sp_desktop_selection(desktop)->singleItem(); } - menu = sp_ui_context_menu(desktop, item); - gtk_widget_show(menu); + ContextMenu* CM = new ContextMenu(desktop, item); + CM->show(); switch (event->type) { case GDK_BUTTON_PRESS: - gtk_menu_popup(GTK_MENU(menu), NULL, NULL, 0, NULL, - event->button.button, event->button.time); + CM->popup(event->button.button, event->button.time); break; case GDK_KEY_PRESS: - gtk_menu_popup(GTK_MENU(menu), NULL, NULL, 0, NULL, 0, event->key.time); + CM->popup(0, event->key.time); break; default: break; -- cgit v1.2.3