~ubuntu-branches/ubuntu/natty/unity/natty-proposed

« back to all changes in this revision

Viewing changes to src/PlacesResultsController.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2011-03-01 14:27:16 UTC
  • mfrom: (1.1.33 upstream)
  • Revision ID: james.westby@ubuntu.com-20110301142716-zuky11rmg555t4be
Tags: 3.6.0-0ubuntu1
* New upstream release.
  - Menu bar becomes blank periodically (LP: #683065)
  - Unity does not update when screen resolution changes (LP: #684539)
  - [dash] Keyboard navigation not implemented as specified (LP: #608132)
  - Dash - build the Desktop Dash (LP: #683719)
  - Quicklists not working (LP: #719780)
  - Launcher auto hide animation has a life of it's own / Unity launcher
    constantly sliding in and out without user interaction (LP: #717364)
  - compiz crashed with SIGSEGV in PrivateWindow::getModalTransient()
    (LP: #726235)
  - Don't show launcher number overlays on tap of super (LP: #726630)
  - Optimize texture memory usage for unexposed view icons (LP: #609994)
  - Unity should handle video-out keycodes that correspond to Super + P +
    Enter (LP: #632632)
  - dash - wrong count of remaining items to see (LP: #662605)
  - dash - x search box button visibility (LP: #662614)
  - Touch window management gesture previews (LP: #683688)
  - unity not working on rotated displays (LP: #694596)
  - unity main top bar in displays in wrong area (multi-head issue)
    (LP: #707209)
  - unity place group visual improvements (LP: #714528)
  - Implement ref_state_set for toplevel ATK objects in the panel service
    (LP: #715299)
  - Alt + F1 doesn't show the launcher if hidden (LP: #717125)
  - Keyboard navigation: Choosing a window from launcher doesn't change
    input focus. (LP: #721811)
  - Quicklists not closing when losing focus (LP: #724739)
  - wrong animation in the launcher (LP: #724956)
  - Window management - windows go below launcher and panel (LP: #725463)
  - Media and PrintScreen keys don't work (LP: #621887)
  - super-shortcuts should be "serializable" (LP: #638936)
  - Chromium icon in Unity is distorted / some scaled distored in the unity
    place applications (LP: #670169)
  - launcher stays on screen when it shouldn't | false show/hide positives
    on the launcher (LP: #711176)
  - Keyboard navigation: no public API to know the current Laucher Icon
    selected when key nav is activated (LP: #722660)
  - Require to implement AtkSelection on the Launcher (LP: #723804)
  - LauncherIcon accessibility support requires to expose the selection
    state (LP: #723806)
  - Add keyboard shortcuts for launching separate instances of applications 
    (LP: #724865)
* debian/control:
  - dep on latest nux

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
15
 *
16
16
 * Authored by: Gordon Allott <gord.allott@canonical.com>
 
17
 *              Neil Jagdish Patel <neil.patel@canonical.com>
17
18
 */
18
19
 
19
20
#include "config.h"
20
21
 
21
 
#include "Nux/Nux.h"
22
 
#include "Nux/GridHLayout.h"
23
 
 
24
 
#include "NuxGraphics/GLThread.h"
25
22
#include <glib.h>
26
23
 
27
24
#include "ubus-server.h"
28
25
#include "UBusMessages.h"
29
26
 
 
27
#include "PlacesSettings.h"
 
28
 
30
29
#include "PlacesResultsController.h"
31
 
#include "PlacesGroup.h"
32
 
#include "PlacesSimpleTile.h"
33
 
 
34
 
#include "PlacesSettings.h"
35
30
 
36
31
PlacesResultsController::PlacesResultsController ()
37
32
{
60
55
}
61
56
 
62
57
void
63
 
PlacesResultsController::AddResultToGroup (const char *groupname,
64
 
                                           PlacesTile *tile,
65
 
                                           void       *_id)
66
 
{
67
 
  PlacesGroup *group = _groups[groupname];
 
58
PlacesResultsController::AddGroup (PlaceEntryGroup& group)
 
59
{
 
60
  PlacesGroupController *controller = new PlacesGroupController (group);
 
61
 
 
62
  _id_to_group[group.GetId ()] = controller;
 
63
  _results_view->AddGroup (controller->GetGroup ());
 
64
  _results_view->QueueRelayout ();
 
65
}
 
66
 
 
67
void
 
68
PlacesResultsController::AddResult (PlaceEntryGroup& group, PlaceEntryResult& result)
 
69
{
 
70
  PlacesGroupController *controller = _id_to_group[group.GetId ()];
 
71
 
 
72
  // We don't complain here because there are some shortcuts that the PlacesView takes which
 
73
  // mean we sometimes receive requests that we can't process
 
74
  if (!controller)
 
75
    return;
 
76
 
 
77
  controller->AddResult (group, result);
 
78
}
 
79
 
 
80
void
 
81
PlacesResultsController::RemoveResult (PlaceEntryGroup& group, PlaceEntryResult& result)
 
82
{
 
83
  PlacesGroupController *controller = _id_to_group[group.GetId ()];
 
84
 
 
85
  // We don't complain here because there are some shortcuts that the PlacesView takes which
 
86
  // mean we sometimes receive requests that we can't process
 
87
  if (!controller)
 
88
    return;
 
89
 
 
90
  controller->RemoveResult (group, result);
 
91
}
 
92
 
 
93
void
 
94
PlacesResultsController::Clear ()
 
95
{
 
96
  std::map <const void *, PlacesGroupController *>::iterator it, eit = _id_to_group.end ();
68
97
  
69
 
  if (!group)
70
 
    {
71
 
      group = CreateGroup (groupname);
72
 
    }
73
 
 
74
 
  group->GetLayout ()->AddView (tile, 1, nux::eLeft, nux::eFull);
75
 
  _tiles[_id] = tile;
76
 
  _tile_group_relations[_id] = groupname;
77
 
 
78
 
  // Should also catch the onclick signal here on each tile,
79
 
  // so we can activate or do whatever it is we need to do
80
 
 
81
 
  if (group->IsVisible () == false)
82
 
  {
83
 
    group->SetVisible (true);
84
 
    group->Relayout ();
85
 
  }
86
 
 
87
 
  tile->QueueDraw ();
88
 
}
89
 
 
90
 
void
91
 
PlacesResultsController::RemoveResultFromGroup (const char *groupname,
92
 
                                                void       *_id)
93
 
{
94
 
  PlacesTile *tile = _tiles[_id];
95
 
  PlacesGroup *group = _groups[groupname];
96
 
 
97
 
  if (group)
98
 
  {
99
 
    if (tile)
100
 
    {
101
 
      group->GetLayout ()->RemoveChildObject (tile);
102
 
 
103
 
      if (group->GetLayout ()->GetChildren ().empty ())
104
 
      {
105
 
        group->SetVisible (false);
106
 
      }
107
 
      else
108
 
      {
109
 
        group->Relayout ();
110
 
      }
111
 
    }
112
 
    else
113
 
    {
114
 
      g_warning ("Unable to remove '%p' from group '%s': Unable to find tile",
115
 
                 _id, groupname);
116
 
    }
117
 
  }
118
 
  else
119
 
  {
120
 
    g_warning ("Unable to remove '%p' from group '%s': Unable to find group",
121
 
               _id, groupname);
122
 
  }
123
 
 
124
 
  _tiles.erase (_id);
125
 
  _tile_group_relations.erase (_id);
126
 
}
127
 
 
128
 
void
129
 
PlacesResultsController::RemoveResult (void *_id)
130
 
{
131
 
  RemoveResultFromGroup (_tile_group_relations [_id].c_str (), _id);
132
 
}
133
 
 
134
 
void
135
 
PlacesResultsController::Clear ()
136
 
{
137
 
  std::map<std::string, PlacesGroup *>::iterator it;
138
 
 
139
 
  for (it = _groups.begin (); it != _groups.end (); ++it)
140
 
  {
141
 
    PlacesGroup *group = dynamic_cast <PlacesGroup *> (it->second);
142
 
    
143
 
    if (group)
144
 
    {
145
 
      _results_view->RemoveGroup (group);
146
 
      group->UnReference ();
147
 
    }
148
 
  }
149
 
 
150
 
  _groups.erase (_groups.begin (), _groups.end ());
151
 
  _tiles.erase (_tiles.begin (), _tiles.end ());
152
 
  _tile_group_relations.erase (_tile_group_relations.begin (), _tile_group_relations.end ());
153
 
}
154
 
 
155
 
PlacesGroup *
156
 
PlacesResultsController::CreateGroup (const char *groupname, const char *icon)
157
 
{
158
 
  PlacesSettings *settings = PlacesSettings::GetDefault ();
159
 
 
160
 
  PlacesGroup *newgroup = new PlacesGroup (NUX_TRACKER_LOCATION);
161
 
  newgroup->SinkReference ();
162
 
  newgroup->SetTitle (groupname);
163
 
  newgroup->SetEmblem (icon);
164
 
  newgroup->SetRowHeight (92);
165
 
  newgroup->SetItemDetail (1, 100);
166
 
  newgroup->SetExpanded (true);
167
 
 
168
 
  nux::GridHLayout *layout = new nux::GridHLayout (NUX_TRACKER_LOCATION);
169
 
  layout->ForceChildrenSize (true);
170
 
  layout->SetChildrenSize (settings->GetDefaultTileWidth (), 100);
171
 
  layout->EnablePartialVisibility (false);
172
 
 
173
 
  layout->SetVerticalExternalMargin (4);
174
 
  layout->SetHorizontalExternalMargin (4);
175
 
  layout->SetVerticalInternalMargin (4);
176
 
  layout->SetHorizontalInternalMargin (4);
177
 
  layout->SetHeightMatchContent (true);
178
 
 
179
 
  newgroup->AddLayout (layout);
180
 
  newgroup->SetVisible (false);
181
 
 
182
 
  _groups[groupname] = newgroup;
183
 
  _results_view->AddGroup (newgroup);
184
 
 
185
 
  return newgroup;
186
 
}
187
 
 
188
 
 
189
 
/* Introspection */
190
 
const gchar *
 
98
  for (it = _id_to_group.begin (); it != eit; ++it)
 
99
    (it->second)->UnReference ();
 
100
 
 
101
  _id_to_group.erase (_id_to_group.begin (), _id_to_group.end ());
 
102
 
 
103
  _results_view->Clear ();
 
104
}
 
105
 
 
106
 
 
107
//
 
108
// Introspection
 
109
//
 
110
const gchar*
191
111
PlacesResultsController::GetName ()
192
112
{
193
113
  return "PlacesResultsController";
196
116
void
197
117
PlacesResultsController::AddProperties (GVariantBuilder *builder)
198
118
{
 
119
 
199
120
}
200
 
 
201
 
 
202
 
 
203
 
 
204
 
 
205
 
 
206
 
 
207