1// 2// Copyright (C) 2011 Robert Dyer, Rico Tzschichholz 3// 4// This file is part of Plank. 5// 6// Plank is free software: you can redistribute it and/or modify 7// it under the terms of the GNU General Public License as published by 8// the Free Software Foundation, either version 3 of the License, or 9// (at your option) any later version. 10// 11// Plank is distributed in the hope that it will be useful, 12// but WITHOUT ANY WARRANTY; without even the implied warranty of 13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14// GNU General Public License for more details. 15// 16// You should have received a copy of the GNU General Public License 17// along with this program. If not, see <http://www.gnu.org/licenses/>. 18// 19 20namespace Plank 21{ 22 /** 23 * A dock item for the dock itself. Has things like about, help, quit etc. 24 */ 25 public class PlankDockItem : DockItem 26 { 27 static PlankDockItem? instance; 28 29 public static unowned PlankDockItem get_instance () 30 { 31 if (instance == null) 32 instance = new PlankDockItem (); 33 34 return instance; 35 } 36 37 PlankDockItem () 38 { 39 GLib.Object (Prefs: new DockItemPreferences (), Text: "Plank", Icon: "plank"); 40 } 41 42 construct 43 { 44 // if plank is pinned indicate that it is running while it isnt user-visible 45 Indicator = IndicatorState.SINGLE; 46 } 47 48 /** 49 * {@inheritDoc} 50 */ 51 public override bool can_be_removed () 52 { 53 return false; 54 } 55 56 /** 57 * {@inheritDoc} 58 */ 59 protected override AnimationType on_clicked (PopupButton button, Gdk.ModifierType mod, uint32 event_time) 60 { 61 Application.get_default ().activate_action ("preferences", null); 62 63 return AnimationType.DARKEN; 64 } 65 66 /** 67 * {@inheritDoc} 68 */ 69 public override Gee.ArrayList<Gtk.MenuItem> get_menu_items () 70 { 71 var items = new Gee.ArrayList<Gtk.MenuItem> (); 72 73 var item = create_menu_item (_("Get _Help Online..."), "help-browser"); 74 item.activate.connect (() => Application.get_default ().activate_action ("help", null)); 75 items.add (item); 76 77 item = create_menu_item (_("_Translate This Application..."), "preferences-desktop-locale"); 78 item.activate.connect (() => Application.get_default ().activate_action ("translate", null)); 79 items.add (item); 80 81 items.add (new Gtk.SeparatorMenuItem ()); 82 83 item = new Gtk.ImageMenuItem.from_stock (Gtk.Stock.PREFERENCES, null); 84 item.activate.connect (() => Application.get_default ().activate_action ("preferences", null)); 85 items.add (item); 86 87 item = new Gtk.ImageMenuItem.from_stock (Gtk.Stock.ABOUT, null); 88 item.activate.connect (() => Application.get_default ().activate_action ("about", null)); 89 items.add (item); 90 91 // No explicit quit-item on elementary OS 92 if (!environment_is_session_desktop (XdgSessionDesktop.PANTHEON)) { 93 items.add (new Gtk.SeparatorMenuItem ()); 94 95 item = new Gtk.ImageMenuItem.from_stock (Gtk.Stock.QUIT, null); 96 item.activate.connect (() => Application.get_default ().activate_action ("quit", null)); 97 items.add (item); 98 } 99 100 return items; 101 } 102 } 103} 104