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.
5 #ifndef CHROME_BROWSER_UI_LIBGTK2UI_APP_INDICATOR_ICON_H_
6 #define CHROME_BROWSER_UI_LIBGTK2UI_APP_INDICATOR_ICON_H_
8 #include "base/files/file_path.h"
9 #include "base/memory/weak_ptr.h"
10 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h"
11 #include "ui/views/linux_ui/status_icon_linux.h"
13 typedef struct _AppIndicator AppIndicator
;
14 typedef struct _GtkWidget GtkWidget
;
26 class AppIndicatorIcon
: public views::StatusIconLinux
{
28 // The id uniquely identifies the new status icon from other chrome status
30 AppIndicatorIcon(std::string id
,
31 const gfx::ImageSkia
& image
,
32 const base::string16
& tool_tip
);
33 virtual ~AppIndicatorIcon();
35 // Indicates whether libappindicator so could be opened.
36 static bool CouldOpen();
38 // Overridden from views::StatusIconLinux:
39 virtual void SetImage(const gfx::ImageSkia
& image
) OVERRIDE
;
40 virtual void SetPressedImage(const gfx::ImageSkia
& image
) OVERRIDE
;
41 virtual void SetToolTip(const base::string16
& tool_tip
) OVERRIDE
;
42 virtual void UpdatePlatformContextMenu(ui::MenuModel
* menu
) OVERRIDE
;
43 virtual void RefreshPlatformContextMenu() OVERRIDE
;
46 void SetImageFromFile(const base::FilePath
& icon_file_path
);
49 // Adds a menu item to the top of the existing gtk_menu as a replacement for
50 // the status icon click action or creates a new gtk menu with the menu item
51 // if a menu doesn't exist. Clicking on this menu item should simulate a
52 // status icon click by despatching a click event.
53 void CreateClickActionReplacement();
56 // Callback for when the status icon click replacement menu item is clicked.
57 CHROMEGTK_CALLBACK_0(AppIndicatorIcon
, void, OnClick
);
59 // Callback for when a menu item is clicked.
60 CHROMEGTK_CALLBACK_0(AppIndicatorIcon
, void, OnMenuItemActivated
);
63 std::string tool_tip_
;
65 // Gtk status icon wrapper
69 ui::MenuModel
* menu_model_
;
71 base::FilePath icon_file_path_
;
72 int icon_change_count_
;
73 bool block_activation_
;
75 base::WeakPtrFactory
<AppIndicatorIcon
> weak_factory_
;
77 DISALLOW_COPY_AND_ASSIGN(AppIndicatorIcon
);
80 } // namespace libgtk2ui
82 #endif // CHROME_BROWSER_UI_LIBGTK2UI_APP_INDICATOR_ICON_H_