~didrocks/unity/launcher-bug-fix-fest

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*
 * Copyright (C) 2010 Canonical Ltd
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authored by: Gordon Allott <gord.allott@canonical.com>
 *              Neil Jagdish Patel <neil.patel@canonical.com>
 */

#ifndef PLACES_VIEW_H
#define PLACES_VIEW_H

#include <Nux/Nux.h>
#include <Nux/View.h>
#include <NuxImage/CairoGraphics.h>
#include <NuxGraphics/GraphicsEngine.h>
#include <Nux/AbstractPaintLayer.h>
#include <Nux/VLayout.h>
#include <Nux/LayeredLayout.h>

#include "Introspectable.h"

#include "Place.h"
#include "PlaceEntry.h"
#include "PlaceEntryHome.h"
#include "PlaceFactory.h"

#include "PlacesSearchBar.h"
#include "PlacesHomeView.h"
#include "PlacesEmptyView.h"

#include "PlacesResultsController.h"
#include "PlacesResultsView.h"

#include "IconLoader.h"

class PlacesView : public nux::View, public Introspectable
{
  NUX_DECLARE_OBJECT_TYPE (PlacesView, nux::View);
public:

  // Current size of the Dash
  enum SizeMode
  {
    SIZE_MODE_FULLSCREEN,
    SIZE_MODE_HOVER
  };

  // This controls how the Dash resizes to it's contents
  enum ShrinkMode
  {
    SHRINK_MODE_NONE,
    SHRINK_MODE_CONTENTS
  };

  PlacesView (PlaceFactory *factory);
  ~PlacesView ();

  // nux::View overrides
  long ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
  void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
  void DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw);

  // Methods
  void         SetActiveEntry (PlaceEntry *entry,
                               guint       section_id,
                               const char *search_string,
                               bool        signal=true);

  PlaceEntry * GetActiveEntry ();
  
  PlacesResultsController * GetResultsController ();

  nux::TextEntry* GetTextEntryView ();

  // UBus handlers
  void PlaceEntryActivateRequest (const char *entry_id, guint section, const gchar *search);

  SizeMode GetSizeMode ();
  void     SetSizeMode (SizeMode size_mode);

  void AboutToShow ();

  // Signals
  sigc::signal<void, PlaceEntry *> entry_changed;
  sigc::signal<void> fullscreen_request;
 
protected:

  const gchar* GetName ();
  void AddProperties (GVariantBuilder *builder);

private:
  static void CloseRequest (GVariant *data, PlacesView *self);

  void OnGroupAdded    (PlaceEntry *entry, PlaceEntryGroup& group);
  void OnResultAdded   (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result);
  void OnResultRemoved (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result);

  bool TryPlaceActivation (const char *uri);
  static void OnResultActivated (GVariant *data, PlacesView *self);
  void OnSearchChanged (const char *search_string);
  void OnResultsViewGeometryChanged (nux::Area *view, nux::Geometry& view_geo);

  static void OnPlaceViewQueueDrawNeeded (GVariant *data, PlacesView *self);

  void OnEntryActivated ();

  void LoadPlaces ();
  void OnPlaceAdded (Place *place);
  void OnPlaceResultActivated (const char *uri, ActivationResult res);
  void ReEvaluateShrinkMode ();

  static gboolean OnResizeFrame (PlacesView *self);

  void OnSearchFinished (const char *search_string,
                         guint32     section_id,
                         std::map<const char *, const char *>& hints);

  static gboolean OnSearchTimedOut (PlacesView *view);

private:
  PlaceFactory       *_factory;
  nux::HLayout       *_layout;
  nux::LayeredLayout *_layered_layout;
  PlacesSearchBar    *_search_bar;
  PlacesHomeView     *_home_view;
  PlacesEmptyView    *_empty_view;
  PlaceEntryHome     *_home_entry;
  PlaceEntry         *_entry;
  sigc::connection    _group_added_conn;
  sigc::connection    _result_added_conn;
  sigc::connection    _result_removed_conn;
  sigc::connection    _search_finished_conn;

  PlacesResultsController *_results_controller;
  PlacesResultsView       *_results_view;

  IconLoader       *_icon_loader;
  nux::ColorLayer  *_bg_layer;
  nux::SpaceLayout *_h_spacer;
  nux::SpaceLayout *_v_spacer;

  SizeMode   _size_mode;
  ShrinkMode _shrink_mode;

  nux::ObjectPtr <nux::IOpenGLBaseTexture> _bg_blur_texture;
  nux::Geometry _bg_blur_geo;

  gint   _target_height;
  gint   _actual_height;
  guint  _resize_id;
  gint   _last_height;
  gint64 _resize_start_time;

  PlaceEntry *_alt_f2_entry;

  guint _n_results;
  guint _searching_timeout;
  bool  _pending_activation;
};

#endif // PANEL_HOME_BUTTON_H