OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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_APP_INDICATOR_ICON_H_ |
| 6 #define CHROME_BROWSER_UI_LIBGTK2UI_APP_INDICATOR_ICON_H_ |
| 7 |
| 8 #include "base/files/file_path.h" |
| 9 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" |
| 10 #include "ui/linux_ui/status_icon_linux.h" |
| 11 |
| 12 typedef struct _AppIndicator AppIndicator; |
| 13 typedef struct _GtkWidget GtkWidget; |
| 14 |
| 15 namespace gfx { |
| 16 class ImageSkia; |
| 17 } |
| 18 |
| 19 namespace libgtk2ui { |
| 20 |
| 21 class AppIndicatorIcon : public StatusIconLinux { |
| 22 public: |
| 23 // The id uniquely identifies the new status icon from other chrome status |
| 24 // icons. |
| 25 explicit AppIndicatorIcon(std::string id); |
| 26 virtual ~AppIndicatorIcon(); |
| 27 |
| 28 // Indicates whether libappindicator so could be opened. |
| 29 static bool CouldOpen(); |
| 30 |
| 31 // Overridden from StatusIcon: |
| 32 virtual void SetImage(const gfx::ImageSkia& image) OVERRIDE; |
| 33 virtual void SetPressedImage(const gfx::ImageSkia& image) OVERRIDE; |
| 34 virtual void SetToolTip(const string16& tool_tip) OVERRIDE; |
| 35 virtual void SetClickActionLabel(const string16& label) OVERRIDE; |
| 36 |
| 37 protected: |
| 38 // Overridden from StatusIcon. |
| 39 virtual void UpdatePlatformContextMenu(ui::MenuModel* menu) OVERRIDE; |
| 40 |
| 41 private: |
| 42 void SetImageFromFile(base::FilePath icon_file_path); |
| 43 void SetMenu(); |
| 44 |
| 45 // Adds a menu item to the top of the existing gtk_menu as a replacement for |
| 46 // the status icon click action or creates a new gtk menu with the menu item |
| 47 // if a menu doesn't exist. Clicking on this menu item should simulate a |
| 48 // status icon click by despatching a click event. |
| 49 void CreateClickActionReplacement(); |
| 50 void DestroyMenu(); |
| 51 |
| 52 static base::FilePath CreateTempImageFile(gfx::ImageSkia image, |
| 53 int icon_change_count, |
| 54 std::string id); |
| 55 static void DeletePath(base::FilePath icon_file_path); |
| 56 |
| 57 // Updates all the enabled/checked states and the dynamic labels. |
| 58 void UpdateMenu(); |
| 59 |
| 60 // Callback for when the status icon click replacement menu item is clicked. |
| 61 CHROMEGTK_CALLBACK_0(AppIndicatorIcon, void, OnClick); |
| 62 |
| 63 // Callback for when a menu item is clicked. |
| 64 CHROMEGTK_CALLBACK_0(AppIndicatorIcon, void, OnMenuItemActivated); |
| 65 |
| 66 std::string id_; |
| 67 std::string click_action_label_; |
| 68 |
| 69 // Gtk status icon wrapper |
| 70 AppIndicator* icon_; |
| 71 |
| 72 GtkWidget* gtk_menu_; |
| 73 ui::MenuModel* menu_model_; |
| 74 |
| 75 base::FilePath icon_file_path_; |
| 76 int icon_change_count_; |
| 77 bool block_activation_; |
| 78 bool has_click_action_replacement_; |
| 79 }; |
| 80 |
| 81 } // namespace libgtk2ui |
| 82 |
| 83 #endif // CHROME_BROWSER_UI_LIBGTK2UI_APP_INDICATOR_ICON_H_ |
OLD | NEW |