Home | History | Annotate | Download | only in gtk
      1 /*
      2  *  Copyright (C) 2007 Holger Hans Peter Freyther
      3  * Portions Copyright (c) 2010 Motorola Mobility, Inc.  All rights reserved.
      4  *
      5  *  This library is free software; you can redistribute it and/or
      6  *  modify it under the terms of the GNU Lesser General Public
      7  *  License as published by the Free Software Foundation; either
      8  *  version 2 of the License, or (at your option) any later version.
      9  *
     10  *  This library is distributed in the hope that it will be useful,
     11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13  *  Lesser General Public License for more details.
     14  *
     15  *  You should have received a copy of the GNU Lesser General Public
     16  *  License along with this library; if not, write to the Free Software
     17  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
     18  */
     19 
     20 #include "config.h"
     21 #include "ContextMenu.h"
     22 
     23 #include "NotImplemented.h"
     24 #include <gtk/gtk.h>
     25 
     26 namespace WebCore {
     27 
     28 ContextMenu::ContextMenu()
     29 {
     30     m_platformDescription = GTK_MENU(gtk_menu_new());
     31 }
     32 
     33 ContextMenu::~ContextMenu()
     34 {
     35     if (m_platformDescription)
     36         gtk_widget_destroy(GTK_WIDGET(m_platformDescription));
     37 }
     38 
     39 void ContextMenu::appendItem(ContextMenuItem& item)
     40 {
     41     ASSERT(m_platformDescription);
     42 
     43     GtkMenuItem* platformItem = item.releasePlatformDescription();
     44     ASSERT(platformItem);
     45     gtk_menu_shell_append(GTK_MENU_SHELL(m_platformDescription), GTK_WIDGET(platformItem));
     46     gtk_widget_show(GTK_WIDGET(platformItem));
     47 }
     48 
     49 void ContextMenu::setPlatformDescription(PlatformMenuDescription menu)
     50 {
     51     ASSERT(menu);
     52     if (m_platformDescription)
     53         gtk_widget_destroy(GTK_WIDGET(m_platformDescription));
     54 
     55     m_platformDescription = menu;
     56 }
     57 
     58 PlatformMenuDescription ContextMenu::platformDescription() const
     59 {
     60     return m_platformDescription;
     61 }
     62 
     63 PlatformMenuDescription ContextMenu::releasePlatformDescription()
     64 {
     65     PlatformMenuDescription description = m_platformDescription;
     66     m_platformDescription = 0;
     67 
     68     return description;
     69 }
     70 
     71 Vector<ContextMenuItem> contextMenuItemVector(const PlatformMenuDescription)
     72 {
     73     notImplemented();
     74 
     75     Vector<ContextMenuItem> menuItemVector;
     76     return menuItemVector;
     77 }
     78 
     79 }
     80