Home | History | Annotate | Download | only in libgtk2ui
      1 // Copyright 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_UI_LIBGTK2UI_MENU_UTIL_H_
      6 #define CHROME_BROWSER_UI_LIBGTK2UI_MENU_UTIL_H_
      7 
      8 #include <gtk/gtk.h>
      9 
     10 #include "ui/gfx/image/image.h"
     11 
     12 namespace ui {
     13 class MenuModel;
     14 }
     15 
     16 namespace libgtk2ui {
     17 // Builds GtkImageMenuItems.
     18 GtkWidget* BuildMenuItemWithImage(const std::string& label, GtkWidget* image);
     19 GtkWidget* BuildMenuItemWithImage(const std::string& label,
     20                                   const gfx::Image& icon);
     21 GtkWidget* BuildMenuItemWithLabel(const std::string& label);
     22 
     23 ui::MenuModel* ModelForMenuItem(GtkMenuItem* menu_item);
     24 
     25 // This method is used to build the menu dynamically. The return value is the
     26 // new menu item.
     27 GtkWidget* AppendMenuItemToMenu(int index,
     28                                 ui::MenuModel* model,
     29                                 GtkWidget* menu_item,
     30                                 GtkWidget* menu,
     31                                 bool connect_to_activate,
     32                                 GCallback item_activated_cb,
     33                                 void* this_ptr);
     34 
     35 // Gets the ID of a menu item.
     36 // Returns true if the menu item has an ID.
     37 bool GetMenuItemID(GtkWidget* menu_item, int* menu_id);
     38 
     39 // Execute command associated with specified id.
     40 void ExecuteCommand(ui::MenuModel* model, int id);
     41 
     42 // Creates a GtkMenu from |model_|. block_activation_ptr is used to disable
     43 // the item_activated_callback while we set up the set up the menu items.
     44 // See comments in definition of SetMenuItemInfo for more info.
     45 void BuildSubmenuFromModel(ui::MenuModel* model,
     46                            GtkWidget* menu,
     47                            GCallback item_activated_cb,
     48                            bool* block_activation,
     49                            void* this_ptr);
     50 
     51 // Sets the check mark, enabled/disabled state and dynamic labels on menu items.
     52 void SetMenuItemInfo(GtkWidget* widget, void* block_activation_ptr);
     53 
     54 }  // namespace libgtk2ui
     55 
     56 #endif  // CHROME_BROWSER_UI_LIBGTK2UI_MENU_UTIL_H_
     57