~3v1n0/unity/overlay-border-scale

« back to all changes in this revision

Viewing changes to plugins/unityshell/src/BamfLauncherIcon.h

  • Committer: Daniel van Vugt
  • Date: 2012-03-14 06:24:18 UTC
  • mfrom: (2108 unity)
  • mto: This revision was merged to the branch mainline in revision 2146.
  • Revision ID: daniel.van.vugt@canonical.com-20120314062418-nprucpbr0m7qky5e
Merged latest lp:unity

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2
2
/*
3
 
 * Copyright (C) 2010 Canonical Ltd
 
3
 * Copyright (C) 2010-2012 Canonical Ltd
4
4
 *
5
5
 * This program is free software: you can redistribute it and/or modify
6
6
 * it under the terms of the GNU General Public License version 3 as
15
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
16
 *
17
17
 * Authored by: Jason Smith <jason.smith@canonical.com>
 
18
 *              Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
18
19
 */
19
20
 
20
21
#ifndef BAMFLAUNCHERICON_H
21
22
#define BAMFLAUNCHERICON_H
22
23
 
23
 
/* Compiz */
24
 
#include <core/core.h>
 
24
#include <UnityCore/GLibSignal.h>
 
25
#include <UnityCore/GLibWrapper.h>
25
26
 
26
 
#include <Nux/BaseWindow.h>
27
 
#include <NuxCore/Math/MathInc.h>
28
 
#include <gdk-pixbuf/gdk-pixbuf.h>
29
27
#include <libbamf/libbamf.h>
30
 
#include <sigc++/sigc++.h>
 
28
#include <libindicator/indicator-desktop-shortcuts.h>
31
29
 
32
30
#include "SimpleLauncherIcon.h"
33
31
 
40
38
 
41
39
class BamfLauncherIcon : public SimpleLauncherIcon
42
40
{
 
41
  NUX_DECLARE_OBJECT_TYPE(BamfLauncherIcon, SimpleLauncherIcon);
43
42
public:
44
 
  BamfLauncherIcon(Launcher* IconManager, BamfApplication* app);
 
43
  BamfLauncherIcon(BamfApplication* app);
45
44
  virtual ~BamfLauncherIcon();
46
45
 
47
 
  const char* DesktopFile();
48
 
  bool IsSticky();
 
46
  void ActivateLauncherIcon(ActionArg arg);
 
47
 
 
48
  std::string DesktopFile();
 
49
 
 
50
  bool IsSticky() const;
 
51
  bool IsVisible() const;
 
52
  bool IsActive() const;
 
53
  bool IsRunning() const;
 
54
  bool IsUrgent() const;
 
55
 
49
56
  void Quit();
50
 
  void Stick();
 
57
  void Stick(bool save = true);
51
58
  void UnStick();
52
59
 
53
 
  void ActivateLauncherIcon(ActionArg arg);
54
 
 
55
 
  virtual bool ShowInSwitcher();
 
60
  virtual bool ShowInSwitcher(bool current);
56
61
  virtual unsigned long long SwitcherPriority();
57
62
 
58
 
  std::vector<Window> RelatedXids ();
59
 
 
60
 
  std::string NameForWindow (Window window);
 
63
  std::vector<Window> Windows();
 
64
  std::vector<Window> WindowsForMonitor(int monitor);
 
65
  std::string NameForWindow(Window window);
61
66
 
62
67
protected:
63
 
  std::list<DbusmenuMenuitem*> GetMenus();
64
 
 
65
 
  void UpdateIconGeometries(nux::Point3 center);
66
 
  void OnCenterStabilized(nux::Point3 center);
67
 
 
68
 
  void OnLauncherHiddenChanged();
69
 
 
 
68
  void UpdateIconGeometries(std::vector<nux::Point3> center);
 
69
  void OnCenterStabilized(std::vector<nux::Point3> center);
70
70
  void AddProperties(GVariantBuilder* builder);
71
 
 
72
 
  const gchar* GetRemoteUri();
73
 
 
74
 
  nux::DndAction OnQueryAcceptDrop(unity::DndData& dnd_data);
75
71
  void OnAcceptDrop(unity::DndData& dnd_data);
76
72
  void OnDndEnter();
 
73
  void OnDndHovered();
77
74
  void OnDndLeave();
78
 
 
79
75
  void OpenInstanceLauncherIcon(ActionArg arg);
80
 
 
 
76
  void ToggleSticky();
 
77
 
 
78
  nux::DndAction OnQueryAcceptDrop(unity::DndData& dnd_data);
 
79
 
 
80
  std::list<DbusmenuMenuitem*> GetMenus();
81
81
  std::set<std::string> ValidateUrisForLaunch(unity::DndData& dnd_data);
82
82
 
83
 
  const char* BamfName();
 
83
  const gchar* GetRemoteUri();
 
84
  std::string BamfName() const;
84
85
 
85
 
  bool HandlesSpread () { return true; }
 
86
  bool HandlesSpread() { return true; }
 
87
  std::string GetName() const;
86
88
 
87
89
private:
88
 
  BamfApplication* m_App;
89
 
  Launcher* _launcher;
90
 
  std::map<std::string, DbusmenuClient*> _menu_clients;
91
 
  std::map<std::string, DbusmenuMenuitem*> _menu_items;
92
 
  std::map<std::string, DbusmenuMenuitem*> _menu_items_extra;
93
 
  std::map<std::string, gulong> _menu_callbacks;
94
 
  DbusmenuMenuitem* _menu_desktop_shortcuts;
95
 
  gchar* _remote_uri;
96
 
  bool _dnd_hovered;
97
 
  guint _dnd_hover_timer;
98
 
 
99
 
  gchar* _cached_desktop_file;
100
 
  gchar* _cached_name;
101
 
 
102
 
  GFileMonitor* _desktop_file_monitor;
103
 
  gulong _on_desktop_file_changed_handler_id;
104
 
 
105
 
  std::set<std::string> _supported_types;
106
 
  bool _supported_types_filled;
107
 
  guint _fill_supported_types_id;
108
 
  guint32 _window_moved_id;
109
 
  guint32 _window_moved_xid;
110
 
 
111
90
  void EnsureWindowState();
112
 
 
 
91
  void EnsureMenuItemsReady();
113
92
  void UpdateDesktopFile();
114
93
  void UpdateMenus();
115
94
  void UpdateDesktopQuickList();
 
95
  void FillSupportedTypes();
116
96
 
117
97
  void OpenInstanceWithUris(std::set<std::string> uris);
118
98
  void Focus(ActionArg arg);
119
99
  bool Spread(bool current_desktop, int state, bool force);
120
100
 
121
 
  void EnsureMenuItemsReady();
122
 
 
123
101
  void OnWindowMinimized(guint32 xid);
124
102
  void OnWindowMoved(guint32 xid);
125
 
  bool OwnsWindow(Window w);
126
 
  
 
103
 
 
104
  bool OwnsWindow(Window w) const;
 
105
 
127
106
  const std::set<std::string>& GetSupportedTypes();
128
107
 
129
 
  static void OnClosed(BamfView* view, gpointer data);
130
 
  static void OnUserVisibleChanged(BamfView* view, gboolean visible, gpointer data);
131
 
  static void OnActiveChanged(BamfView* view, gboolean active, gpointer data);
132
 
  static void OnRunningChanged(BamfView* view, gboolean running, gpointer data);
133
 
  static void OnUrgentChanged(BamfView* view, gboolean urgent, gpointer data);
134
 
  static void OnChildAdded(BamfView* view, BamfView* child, gpointer data);
135
 
  static void OnChildRemoved(BamfView* view, BamfView* child, gpointer data);
136
 
 
137
 
  static void OnQuit(DbusmenuMenuitem* item, int time, BamfLauncherIcon* self);
138
 
  static void OnLaunch(DbusmenuMenuitem* item, int time, BamfLauncherIcon* self);
139
 
  static void OnTogglePin(DbusmenuMenuitem* item, int time, BamfLauncherIcon* self);
140
 
 
141
 
  static void OnDesktopFileChanged(GFileMonitor*        monitor,
142
 
                                   GFile*               file,
143
 
                                   GFile*               other_file,
144
 
                                   GFileMonitorEvent    event_type,
145
 
                                   gpointer             data);
146
 
 
147
 
  static gboolean OnDndHoveredTimeout(gpointer data);
148
 
  static gboolean FillSupportedTypes(gpointer data);
 
108
 
 
109
  glib::Object<BamfApplication> _bamf_app;
 
110
  bool _dnd_hovered;
 
111
  guint _dnd_hover_timer;
 
112
 
 
113
  bool _supported_types_filled;
 
114
  guint _fill_supported_types_id;
 
115
  guint _window_moved_id;
 
116
 
 
117
  std::string _remote_uri;
 
118
  std::string _desktop_file;
 
119
  std::set<std::string> _supported_types;
 
120
  std::map<std::string, glib::Object<DbusmenuClient>> _menu_clients;
 
121
  std::map<std::string, glib::Object<DbusmenuMenuitem>> _menu_items;
 
122
  std::map<std::string, glib::Object<DbusmenuMenuitem>> _menu_items_extra;
 
123
  glib::Object<IndicatorDesktopShortcuts> _desktop_shortcuts;
 
124
  glib::Object<DbusmenuMenuitem> _menu_desktop_shortcuts;
 
125
  glib::Object<GFileMonitor> _desktop_file_monitor;
 
126
  glib::SignalManager _gsignals;
149
127
};
150
128
 
151
129
}