Home | History | Annotate | Download | only in libgtk2ui
      1 // Copyright 2014 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_APP_INDICATOR_ICON_MENU_H_
      6 #define CHROME_BROWSER_UI_LIBGTK2UI_APP_INDICATOR_ICON_MENU_H_
      7 
      8 #include "base/callback.h"
      9 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h"
     10 
     11 typedef struct _GtkMenu GtkMenu;
     12 typedef struct _GtkWidget GtkWidget;
     13 
     14 namespace ui {
     15 class MenuModel;
     16 }
     17 
     18 namespace libgtk2ui {
     19 
     20 // The app indicator icon's menu.
     21 class AppIndicatorIconMenu {
     22  public:
     23   explicit AppIndicatorIconMenu(ui::MenuModel* model);
     24   virtual ~AppIndicatorIconMenu();
     25 
     26   // Sets a menu item at the top of |gtk_menu_| as a replacement for the app
     27   // indicator icon's click action. |callback| is called when the menu item
     28   // is activated.
     29   void UpdateClickActionReplacementMenuItem(const char* label,
     30                                             const base::Closure& callback);
     31 
     32   // Refreshes all the menu item labels and menu item checked/enabled states.
     33   void Refresh();
     34 
     35   GtkMenu* GetGtkMenu();
     36 
     37  private:
     38   // Callback for when the "click action replacement" menu item is activated.
     39   CHROMEGTK_CALLBACK_0(AppIndicatorIconMenu,
     40                        void,
     41                        OnClickActionReplacementMenuItemActivated);
     42 
     43   // Callback for when a menu item is activated.
     44   CHROMEGTK_CALLBACK_0(AppIndicatorIconMenu, void, OnMenuItemActivated);
     45 
     46   // Not owned.
     47   ui::MenuModel* menu_model_;
     48 
     49   // Whether a "click action replacement" menu item has been added to the menu.
     50   bool click_action_replacement_menu_item_added_;
     51 
     52   // Called when the click action replacement menu item is activated. When a
     53   // menu item from |menu_model_| is activated, MenuModel::ActivatedAt() is
     54   // invoked and is assumed to do any necessary processing.
     55   base::Closure click_action_replacement_callback_;
     56 
     57   GtkWidget* gtk_menu_;
     58 
     59   bool block_activation_;
     60 
     61   DISALLOW_COPY_AND_ASSIGN(AppIndicatorIconMenu);
     62 };
     63 
     64 }  // namespace libgtk2ui
     65 
     66 #endif  // CHROME_BROWSER_UI_LIBGTK2UI_APP_INDICATOR_ICON_MENU_H_
     67