Merge lp:~unity-team/unity/fixes-2011-03-28 into lp:unity

Proposed by Neil J. Patel
Status: Merged
Merged at revision: 1058
Proposed branch: lp:~unity-team/unity/fixes-2011-03-28
Merge into: lp:unity
Diff against target: 852 lines (+442/-61)
19 files modified
src/IndicatorObjectFactoryRemote.cpp (+5/-0)
src/IndicatorObjectFactoryRemote.h (+2/-0)
src/PanelController.cpp (+8/-1)
src/PanelController.h (+2/-0)
src/PanelHomeButton.cpp (+7/-4)
src/PanelMenuView.cpp (+6/-0)
src/PanelMenuView.h (+2/-0)
src/PanelView.cpp (+9/-37)
src/PlacesGroupController.cpp (+42/-15)
src/PlacesGroupController.h (+7/-0)
src/PlacesHorizontalTile.cpp (+244/-0)
src/PlacesHorizontalTile.h (+68/-0)
src/PlacesSearchBar.cpp (+10/-0)
src/PlacesSearchBar.h (+1/-0)
src/PlacesView.cpp (+10/-0)
src/SimpleLauncherIcon.cpp (+2/-1)
src/StaticCairoText.cpp (+12/-3)
src/StaticCairoText.h (+3/-0)
tests/CMakeLists.txt (+2/-0)
To merge this branch: bzr merge lp:~unity-team/unity/fixes-2011-03-28
Reviewer Review Type Date Requested Status
Jason Smith (community) Approve
Review via email: mp+55814@code.launchpad.net

Description of the change

Bugs linked

To post a comment you must log in.
Revision history for this message
Jason Smith (jassmith) wrote :

+1, awesome work, fixes much many crashes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/IndicatorObjectFactoryRemote.cpp'
--- src/IndicatorObjectFactoryRemote.cpp 2011-03-17 14:16:13 +0000
+++ src/IndicatorObjectFactoryRemote.cpp 2011-03-31 19:28:30 +0000
@@ -406,6 +406,11 @@
406 g_free (uname);406 g_free (uname);
407}407}
408408
409GDBusProxy *
410IndicatorObjectFactoryRemote::GetRemoteProxy ()
411{
412 return _proxy;
413}
409 414
410//415//
411// C callbacks, they just link to class methods and aren't interesting416// C callbacks, they just link to class methods and aren't interesting
412417
=== modified file 'src/IndicatorObjectFactoryRemote.h'
--- src/IndicatorObjectFactoryRemote.h 2011-03-17 09:41:28 +0000
+++ src/IndicatorObjectFactoryRemote.h 2011-03-31 19:28:30 +0000
@@ -50,6 +50,8 @@
5050
51 void AddProperties (GVariantBuilder *builder);51 void AddProperties (GVariantBuilder *builder);
5252
53 GDBusProxy * GetRemoteProxy ();
54
53private:55private:
54 IndicatorObjectProxyRemote* IndicatorForID (const char *id);56 IndicatorObjectProxyRemote* IndicatorForID (const char *id);
55private:57private:
5658
=== modified file 'src/PanelController.cpp'
--- src/PanelController.cpp 2011-03-29 12:23:52 +0000
+++ src/PanelController.cpp 2011-03-31 19:28:30 +0000
@@ -25,7 +25,8 @@
2525
26PanelController::PanelController ()26PanelController::PanelController ()
27: _bfb_size (66),27: _bfb_size (66),
28 _opacity (1.0f)28 _opacity (1.0f),
29 _open_menu_start_received (false)
29{30{
30 UScreen *screen = UScreen::GetDefault ();31 UScreen *screen = UScreen::GetDefault ();
3132
@@ -63,6 +64,8 @@
6364
64 view->StartFirstMenuShow ();65 view->StartFirstMenuShow ();
65 }66 }
67
68 _open_menu_start_received = true;
66}69}
6770
68void71void
@@ -70,6 +73,10 @@
70{73{
71 std::vector<nux::BaseWindow *>::iterator it, eit = _windows.end ();74 std::vector<nux::BaseWindow *>::iterator it, eit = _windows.end ();
7275
76 if (!_open_menu_start_received)
77 return;
78 _open_menu_start_received = false;
79
73 for (it = _windows.begin (); it != eit; ++it)80 for (it = _windows.begin (); it != eit; ++it)
74 {81 {
75 PanelView *view = ViewForWindow (*it);82 PanelView *view = ViewForWindow (*it);
7683
=== modified file 'src/PanelController.h'
--- src/PanelController.h 2011-03-29 12:23:52 +0000
+++ src/PanelController.h 2011-03-31 19:28:30 +0000
@@ -55,6 +55,8 @@
55 float _opacity;55 float _opacity;
56 56
57 sigc::connection _on_screen_change_connection;57 sigc::connection _on_screen_change_connection;
58
59 bool _open_menu_start_received;
58};60};
5961
60#endif // _PANEL_CONTROLLER_H_62#endif // _PANEL_CONTROLLER_H_
6163
=== modified file 'src/PanelHomeButton.cpp'
--- src/PanelHomeButton.cpp 2011-03-29 12:23:52 +0000
+++ src/PanelHomeButton.cpp 2011-03-31 19:28:30 +0000
@@ -113,10 +113,13 @@
113 cairo_set_line_width (cr, 1);113 cairo_set_line_width (cr, 1);
114114
115 pixbuf = PanelStyle::GetDefault ()->GetHomeButton ();115 pixbuf = PanelStyle::GetDefault ()->GetHomeButton ();
116 gdk_cairo_set_source_pixbuf (cr, pixbuf,116 if (GDK_IS_PIXBUF (pixbuf))
117 (_button_width-gdk_pixbuf_get_width (pixbuf))/2,117 {
118 (PANEL_HEIGHT-gdk_pixbuf_get_height (pixbuf))/2);118 gdk_cairo_set_source_pixbuf (cr, pixbuf,
119 g_object_unref (pixbuf);119 (_button_width-gdk_pixbuf_get_width (pixbuf))/2,
120 (PANEL_HEIGHT-gdk_pixbuf_get_height (pixbuf))/2);
121 g_object_unref (pixbuf);
122 }
120123
121 cairo_paint (cr);124 cairo_paint (cr);
122125
123126
=== modified file 'src/PanelMenuView.cpp'
--- src/PanelMenuView.cpp 2011-03-30 00:29:57 +0000
+++ src/PanelMenuView.cpp 2011-03-31 19:28:30 +0000
@@ -1066,3 +1066,9 @@
1066{1066{
1067 return _we_control_active;1067 return _we_control_active;
1068}1068}
1069
1070bool
1071PanelMenuView::HasOurWindowFocused ()
1072{
1073 return _is_own_window;
1074}
10691075
=== modified file 'src/PanelMenuView.h'
--- src/PanelMenuView.h 2011-03-29 12:23:52 +0000
+++ src/PanelMenuView.h 2011-03-31 19:28:30 +0000
@@ -93,6 +93,8 @@
93 void SetMonitor (int monitor);93 void SetMonitor (int monitor);
94 bool GetControlsActive ();94 bool GetControlsActive ();
9595
96 bool HasOurWindowFocused ();
97
96protected:98protected:
97 const gchar * GetName ();99 const gchar * GetName ();
98 const gchar * GetChildsName ();100 const gchar * GetChildsName ();
99101
=== modified file 'src/PanelView.cpp'
--- src/PanelView.cpp 2011-03-29 12:23:52 +0000
+++ src/PanelView.cpp 2011-03-31 19:28:30 +0000
@@ -37,10 +37,6 @@
37#include "IndicatorObjectFactoryRemote.h"37#include "IndicatorObjectFactoryRemote.h"
38#include "PanelIndicatorObjectView.h"38#include "PanelIndicatorObjectView.h"
3939
40#define S_NAME "com.canonical.Unity.Panel.Service"
41#define S_PATH "/com/canonical/Unity/Panel/Service"
42#define S_IFACE "com.canonical.Unity.Panel.Service"
43
44NUX_IMPLEMENT_OBJECT_TYPE (PanelView);40NUX_IMPLEMENT_OBJECT_TYPE (PanelView);
4541
46PanelView::PanelView (NUX_FILE_LINE_DECL)42PanelView::PanelView (NUX_FILE_LINE_DECL)
@@ -289,7 +285,8 @@
289 {285 {
290 PanelIndicatorObjectView *view = static_cast<PanelIndicatorObjectView *> (*it);286 PanelIndicatorObjectView *view = static_cast<PanelIndicatorObjectView *> (*it);
291 287
292 if (view->_layout == NULL)288 if (view->_layout == NULL
289 || (view == _menu_view && _menu_view->HasOurWindowFocused ()))
293 continue;290 continue;
294291
295 geo = view->GetAbsoluteGeometry ();292 geo = view->GetAbsoluteGeometry ();
@@ -391,7 +388,8 @@
391 {388 {
392 PanelIndicatorObjectView *view = static_cast<PanelIndicatorObjectView *> (*it);389 PanelIndicatorObjectView *view = static_cast<PanelIndicatorObjectView *> (*it);
393390
394 if (view->_layout == NULL)391 if (view->_layout == NULL
392 || (view == _menu_view && _menu_view->HasOurWindowFocused ()))
395 continue;393 continue;
396394
397 std::list<Area *>::iterator it2;395 std::list<Area *>::iterator it2;
@@ -430,22 +428,6 @@
430 return _is_primary;428 return _is_primary;
431}429}
432430
433static void
434on_sync_geometries_done_cb (GObject *source,
435 GAsyncResult *res,
436 gpointer data)
437{
438 GVariant *args;
439 GError *error = NULL;
440
441 args = g_dbus_proxy_call_finish ((GDBusProxy*) source, res, &error);
442 if (error != NULL)
443 {
444 g_warning ("Error when calling SyncGeometries: %s", error->message);
445 g_error_free (error);
446 }
447}
448
449void431void
450PanelView::SetPrimary (bool primary)432PanelView::SetPrimary (bool primary)
451{433{
@@ -458,8 +440,8 @@
458PanelView::SyncGeometries ()440PanelView::SyncGeometries ()
459{441{
460 GVariantBuilder b;442 GVariantBuilder b;
461 GDBusProxy *bus_proxy;443 GDBusProxy *bus_proxy;
462 GVariant *method_args;444 GVariant *method_args;
463 std::list<Area *>::iterator it;445 std::list<Area *>::iterator it;
464446
465 g_variant_builder_init (&b, G_VARIANT_TYPE ("(a(ssiiii))"));447 g_variant_builder_init (&b, G_VARIANT_TYPE ("(a(ssiiii))"));
@@ -499,26 +481,16 @@
499 method_args = g_variant_builder_end (&b);481 method_args = g_variant_builder_end (&b);
500482
501 // Send geometries to the panel service483 // Send geometries to the panel service
502 bus_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,484 bus_proxy =_remote->GetRemoteProxy ();
503 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
504 NULL,
505 S_NAME,
506 S_PATH,
507 S_IFACE,
508 NULL,
509 NULL);
510 if (bus_proxy != NULL)485 if (bus_proxy != NULL)
511 {486 {
512 g_dbus_proxy_call (bus_proxy, "SyncGeometries", method_args,487 g_dbus_proxy_call (bus_proxy, "SyncGeometries", method_args,
513 G_DBUS_CALL_FLAGS_NONE,488 G_DBUS_CALL_FLAGS_NONE,
514 -1,489 -1,
515 NULL,490 NULL,
516 on_sync_geometries_done_cb,491 NULL,
517 this);492 NULL);
518 g_object_unref (bus_proxy);
519 }493 }
520
521 g_variant_unref (method_args);
522}494}
523495
524void496void
525497
=== modified file 'src/PlacesGroupController.cpp'
--- src/PlacesGroupController.cpp 2011-03-23 18:26:57 +0000
+++ src/PlacesGroupController.cpp 2011-03-31 19:28:30 +0000
@@ -23,11 +23,13 @@
2323
24#include "PlacesStyle.h"24#include "PlacesStyle.h"
25#include "PlacesSimpleTile.h"25#include "PlacesSimpleTile.h"
26#include "PlacesHorizontalTile.h"
2627
27static const guint kPadding = 4;28static const guint kPadding = 4;
2829
29PlacesGroupController::PlacesGroupController (PlaceEntry *entry, PlaceEntryGroup& group)30PlacesGroupController::PlacesGroupController (PlaceEntry *entry, PlaceEntryGroup& group)
30: _entry (entry),31: _type (RENDERER_TYPE_DEFAULT),
32 _entry (entry),
31 _group (NULL),33 _group (NULL),
32 _check_tiles_id (0)34 _check_tiles_id (0)
33{35{
@@ -39,17 +41,23 @@
39 _group->SetName(group.GetName ());41 _group->SetName(group.GetName ());
40 _group->SetIcon (group.GetIcon ());42 _group->SetIcon (group.GetIcon ());
4143
44 if (g_strcmp0 (group.GetRenderer (), "UnityHorizontalTileRenderer") == 0)
45 _type = RENDERER_TYPE_HORI_TILE;
46
42 nux::GridHLayout *layout = new nux::GridHLayout (NUX_TRACKER_LOCATION);47 nux::GridHLayout *layout = new nux::GridHLayout (NUX_TRACKER_LOCATION);
43 layout->ForceChildrenSize (true);48 layout->ForceChildrenSize (true);
44 layout->SetChildrenSize (style->GetTileWidth (), style->GetTileHeight ());
45 layout->EnablePartialVisibility (false);49 layout->EnablePartialVisibility (false);
46
47 layout->SetVerticalExternalMargin (kPadding);50 layout->SetVerticalExternalMargin (kPadding);
48 layout->SetHorizontalExternalMargin (kPadding);51 layout->SetHorizontalExternalMargin (kPadding);
49 layout->SetVerticalInternalMargin (kPadding);52 layout->SetVerticalInternalMargin (kPadding);
50 layout->SetHorizontalInternalMargin (kPadding);53 layout->SetHorizontalInternalMargin (kPadding);
51 layout->SetHeightMatchContent (true);54 layout->SetHeightMatchContent (true);
5255
56 if (_type == RENDERER_TYPE_HORI_TILE)
57 layout->SetChildrenSize (style->GetTileWidth () * 2, style->GetTileIconSize () + 24); //padding
58 else
59 layout->SetChildrenSize (style->GetTileWidth (), style->GetTileHeight ());
60
53 _group->SetChildLayout (layout);61 _group->SetChildLayout (layout);
54 _group->SetVisible (false);62 _group->SetVisible (false);
55 _group->SetExpanded (false);63 _group->SetExpanded (false);
@@ -57,11 +65,19 @@
57 _group->expanded.connect (sigc::mem_fun (this, &PlacesGroupController::CheckTiles));65 _group->expanded.connect (sigc::mem_fun (this, &PlacesGroupController::CheckTiles));
58 style->columns_changed.connect (sigc::mem_fun (this, &PlacesGroupController::CheckTiles));66 style->columns_changed.connect (sigc::mem_fun (this, &PlacesGroupController::CheckTiles));
5967
60 _more_tile = new PlacesSimpleTile ("gtk-add",68 if (_type == RENDERER_TYPE_HORI_TILE)
61 _("Load more results..."),69 _more_tile = new PlacesHorizontalTile ("gtk-add",
62 style->GetTileIconSize (),70 _("Load more results..."),
63 false,71 "",
64 "more-tile");72 style->GetTileIconSize (),
73 false,
74 "more-tile");
75 else
76 _more_tile = new PlacesSimpleTile ("gtk-add",
77 _("Load more results..."),
78 style->GetTileIconSize (),
79 false,
80 "more-tile");
65 _more_tile->Reference ();81 _more_tile->Reference ();
66 _more_tile->sigClick.connect (sigc::mem_fun (this, &PlacesGroupController::MoreTileClicked));82 _more_tile->sigClick.connect (sigc::mem_fun (this, &PlacesGroupController::MoreTileClicked));
67}83}
@@ -95,17 +111,27 @@
95111
96 gchar *result_name;112 gchar *result_name;
97 const gchar *result_icon;113 const gchar *result_icon;
98 PlacesSimpleTile *tile;114 gchar *result_comment;
115 PlacesTile *tile;
99116
100 result_name = g_markup_escape_text (result.GetName (), -1);117 result_name = g_markup_escape_text (result.GetName (), -1);
118 result_comment = g_markup_escape_text (result.GetComment (), -1);
101 result_icon = result.GetIcon ();119 result_icon = result.GetIcon ();
102120
103 tile = new PlacesSimpleTile (result_icon,121 if (_type == RENDERER_TYPE_HORI_TILE)
104 result_name,122 tile = new PlacesHorizontalTile (result_icon,
105 style->GetTileIconSize (),123 result_name,
106 false,124 result_comment,
107 result.GetId ());125 style->GetTileIconSize (),
108 tile->SetURI (result.GetURI ());126 false,
127 result.GetId ());
128 else
129 tile = new PlacesSimpleTile (result_icon,
130 result_name,
131 style->GetTileIconSize (),
132 false,
133 result.GetId ());
134
109 tile->QueueRelayout ();135 tile->QueueRelayout ();
110 tile->sigClick.connect (sigc::mem_fun (this, &PlacesGroupController::TileClicked));136 tile->sigClick.connect (sigc::mem_fun (this, &PlacesGroupController::TileClicked));
111137
@@ -116,6 +142,7 @@
116 _group->SetVisible (true);142 _group->SetVisible (true);
117143
118 g_free (result_name);144 g_free (result_name);
145 g_free (result_comment);
119}146}
120147
121void148void
122149
=== modified file 'src/PlacesGroupController.h'
--- src/PlacesGroupController.h 2011-03-20 16:33:05 +0000
+++ src/PlacesGroupController.h 2011-03-31 19:28:30 +0000
@@ -27,6 +27,12 @@
27#include "PlacesGroup.h"27#include "PlacesGroup.h"
28#include "PlacesTile.h"28#include "PlacesTile.h"
2929
30enum PlacesGroupRendererType
31{
32 RENDERER_TYPE_DEFAULT = 0,
33 RENDERER_TYPE_HORI_TILE
34};
35
30class PlacesGroupController : public nux::Object, public Introspectable36class PlacesGroupController : public nux::Object, public Introspectable
31{37{
32public:38public:
@@ -57,6 +63,7 @@
57 void MoreTileClicked (PlacesTile *tile);63 void MoreTileClicked (PlacesTile *tile);
5864
59private:65private:
66 PlacesGroupRendererType _type;
60 PlaceEntry *_entry;67 PlaceEntry *_entry;
61 PlacesGroup *_group;68 PlacesGroup *_group;
62 const void *_id;69 const void *_id;
6370
=== added file 'src/PlacesHorizontalTile.cpp'
--- src/PlacesHorizontalTile.cpp 1970-01-01 00:00:00 +0000
+++ src/PlacesHorizontalTile.cpp 2011-03-31 19:28:30 +0000
@@ -0,0 +1,244 @@
1/*
2 * Copyright 2011 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the applicable version of the GNU Lesser General Public
12 * License for more details.
13 *
14 * You should have received a copy of both the GNU Lesser General Public
15 * License version 3 along with this program. If not, see
16 * <http://www.gnu.org/licenses/>
17 *
18 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
19 *
20 */
21
22#include "PlacesSettings.h"
23#include "PlacesSettings.h"
24#include "ubus-server.h"
25#include "UBusMessages.h"
26
27#include "PlacesHorizontalTile.h"
28
29#include <Nux/HLayout.h>
30#include <NuxImage/GdkGraphics.h>
31#include <gtk/gtk.h>
32#include <gdk/gdk.h>
33
34PlacesHorizontalTile::PlacesHorizontalTile (const char *icon_name,
35 const char *label,
36 const char *comment,
37 int icon_size,
38 bool defer_icon_loading,
39 const void *id)
40: PlacesTile (NUX_TRACKER_LOCATION, id),
41 _label (NULL),
42 _icon (NULL),
43 _uri (NULL)
44{
45 _label = g_strdup (label);
46 _icon = g_strdup (icon_name);
47 _comment = g_strdup_printf ("<small>%s</small>", comment);
48
49 int w = (PlacesSettings::GetDefault ()->GetDefaultTileWidth () * 2) - icon_size - 24;//padding
50
51 nux::HLayout *layout = new nux::HLayout ("", NUX_TRACKER_LOCATION);
52 layout->AddLayout (new nux::SpaceLayout (0, 0, 12, 12));
53
54 _icontex = new IconTexture (_icon, icon_size, defer_icon_loading);
55 _icontex->SetMinMaxSize (icon_size * 1.5, icon_size);
56 AddChild (_icontex);
57 layout->AddView (_icontex, 0, nux::eCenter, nux::eFull);
58
59 layout->AddLayout (new nux::SpaceLayout (0, 0, 12, 12));
60
61 nux::VLayout *vlayout = new nux::VLayout ("", NUX_TRACKER_LOCATION);
62 layout->AddView (vlayout, 1, nux::eLeft, nux::eFull);
63
64 vlayout->AddLayout (new nux::SpaceLayout (0, 0, 6, 6));
65
66 _cairotext = new nux::StaticCairoText (_label);
67 _cairotext->SetTextAlignment (nux::StaticCairoText::NUX_ALIGN_LEFT);
68 _cairotext->SetMaximumWidth (w);
69 vlayout->AddView (_cairotext, 0, nux::eLeft, nux::eFull);
70
71 _cairotext = new nux::StaticCairoText (_comment);
72 _cairotext->SetTextEllipsize (nux::StaticCairoText::NUX_ELLIPSIZE_END);
73 _cairotext->SetTextAlignment (nux::StaticCairoText::NUX_ALIGN_LEFT);
74 _cairotext->SetLines (-3);
75 _cairotext->SetMaximumWidth (w);
76 _cairotext->SetTextColor (nux::Color (1.0f, 1.0f, 1.0f, 0.8f));
77 vlayout->AddView (_cairotext, 1, nux::eLeft, nux::eFull);
78
79 SetLayout (layout);
80
81 SetDndEnabled (true, false);
82}
83
84
85PlacesHorizontalTile::~PlacesHorizontalTile ()
86{
87 g_free (_comment);
88 g_free (_label);
89 g_free (_icon);
90 g_free (_uri);
91}
92
93void
94PlacesHorizontalTile::DndSourceDragBegin ()
95{
96 Reference ();
97 ubus_server_send_message (ubus_server_get_default (),
98 UBUS_PLACE_VIEW_CLOSE_REQUEST,
99 NULL);
100}
101
102nux::NBitmapData *
103PlacesHorizontalTile::DndSourceGetDragImage ()
104{
105 nux::NBitmapData *result = 0;
106 GdkPixbuf *pbuf;
107 GtkIconTheme *theme;
108 GtkIconInfo *info;
109 GError *error = NULL;
110 GIcon *icon;
111
112 const char *icon_name = _icon;
113 int size = 64;
114
115 if (!icon_name)
116 icon_name = "application-default-icon";
117
118 theme = gtk_icon_theme_get_default ();
119 icon = g_icon_new_for_string (icon_name, NULL);
120
121 if (G_IS_ICON (icon))
122 {
123 info = gtk_icon_theme_lookup_by_gicon (theme, icon, size, (GtkIconLookupFlags)0);
124 g_object_unref (icon);
125 }
126 else
127 {
128 info = gtk_icon_theme_lookup_icon (theme,
129 icon_name,
130 size,
131 (GtkIconLookupFlags) 0);
132 }
133
134 if (!info)
135 {
136 info = gtk_icon_theme_lookup_icon (theme,
137 "application-default-icon",
138 size,
139 (GtkIconLookupFlags) 0);
140 }
141
142 if (gtk_icon_info_get_filename (info) == NULL)
143 {
144 gtk_icon_info_free (info);
145 info = gtk_icon_theme_lookup_icon (theme,
146 "application-default-icon",
147 size,
148 (GtkIconLookupFlags) 0);
149 }
150
151 pbuf = gtk_icon_info_load_icon (info, &error);
152 gtk_icon_info_free (info);
153
154 if (GDK_IS_PIXBUF (pbuf))
155 {
156 nux::GdkGraphics graphics (pbuf);
157 result = graphics.GetBitmap ();
158 g_object_unref (pbuf);
159 }
160
161 return result;
162}
163
164std::list<const char *>
165PlacesHorizontalTile::DndSourceGetDragTypes ()
166{
167 std::list<const char*> result;
168 result.push_back ("text/uri-list");
169 return result;
170}
171
172const char *
173PlacesHorizontalTile::DndSourceGetDataForType (const char *type, int *size, int *format)
174{
175 *format = 8;
176
177 if (_uri)
178 {
179 *size = strlen (_uri);
180 return _uri;
181 }
182 else
183 {
184 *size = 0;
185 return 0;
186 }
187}
188
189void
190PlacesHorizontalTile::DndSourceDragFinished (nux::DndAction result)
191{
192 UnReference ();
193}
194
195nux::Geometry
196PlacesHorizontalTile::GetHighlightGeometry ()
197{
198 nux::Geometry base = GetGeometry ();
199 int width = 0, height = 0;
200
201 _icontex->GetTextureSize (&width, &height);
202
203 _highlight_geometry.x = 12;
204 _highlight_geometry.y = 12;
205 _highlight_geometry.width = width;
206 _highlight_geometry.height = height;
207
208 return _highlight_geometry;
209}
210
211void
212PlacesHorizontalTile::SetURI (const char *uri)
213{
214 if (_uri)
215 g_free (_uri);
216
217 _uri = NULL;
218
219 if (uri)
220 _uri = g_strdup (uri);
221}
222
223const gchar*
224PlacesHorizontalTile::GetName ()
225{
226 return "PlacesHorizontalTile";
227}
228
229const gchar *
230PlacesHorizontalTile::GetChildsName ()
231{
232 return "PlacesHorizontalTileContents";
233}
234
235void
236PlacesHorizontalTile::AddProperties (GVariantBuilder *builder)
237{
238 nux::Geometry geo = GetGeometry ();
239
240 g_variant_builder_add (builder, "{sv}", "x", g_variant_new_int32 (geo.x));
241 g_variant_builder_add (builder, "{sv}", "y", g_variant_new_int32 (geo.y));
242 g_variant_builder_add (builder, "{sv}", "width", g_variant_new_int32 (geo.width));
243 g_variant_builder_add (builder, "{sv}", "height", g_variant_new_int32 (geo.height));
244}
0245
=== added file 'src/PlacesHorizontalTile.h'
--- src/PlacesHorizontalTile.h 1970-01-01 00:00:00 +0000
+++ src/PlacesHorizontalTile.h 2011-03-31 19:28:30 +0000
@@ -0,0 +1,68 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright (C) 2011 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
18 */
19
20#ifndef PLACES_HORIZONTAL_TILE_H
21#define PLACES_HORIZONTAL_TILE_H
22
23#include <sigc++/sigc++.h>
24
25#include "IconTexture.h"
26#include "Introspectable.h"
27#include "PlacesTile.h"
28#include "StaticCairoText.h"
29
30class PlacesHorizontalTile : public Introspectable, public PlacesTile
31{
32public:
33
34 PlacesHorizontalTile (const char *icon,
35 const char *label,
36 const char *comment,
37 int icon_size=64,
38 bool defer_icon_loading=false,
39 const void *id=NULL);
40 ~PlacesHorizontalTile ();
41
42 void SetURI (const char *uri);
43
44protected:
45 nux::Geometry GetHighlightGeometry ();
46
47 const gchar * GetName ();
48 const gchar * GetChildsName ();
49 void AddProperties (GVariantBuilder *builder);
50
51 virtual void DndSourceDragBegin ();
52 virtual nux::NBitmapData * DndSourceGetDragImage ();
53 virtual std::list<const char *> DndSourceGetDragTypes ();
54 virtual const char * DndSourceGetDataForType (const char *type, int *size, int *format);
55 virtual void DndSourceDragFinished (nux::DndAction result);
56
57private:
58 nux::Geometry _highlight_geometry;
59 char* _label;
60 char* _comment;
61 char* _icon;
62 char* _uri;
63 IconTexture *_icontex;
64 nux::StaticCairoText *_cairotext;
65};
66
67
68#endif /* PLACES_HORIZONTAL_TILE_H */
069
=== modified file 'src/PlacesSearchBar.cpp'
--- src/PlacesSearchBar.cpp 2011-03-29 15:24:56 +0000
+++ src/PlacesSearchBar.cpp 2011-03-31 19:28:30 +0000
@@ -103,6 +103,10 @@
103 OnFontChanged (NULL, NULL, this);103 OnFontChanged (NULL, NULL, this);
104104
105 _cursor_moved_conn = _pango_entry->cursor_moved.connect (sigc::mem_fun (this, &PlacesSearchBar::OnLayeredLayoutQueueDraw));105 _cursor_moved_conn = _pango_entry->cursor_moved.connect (sigc::mem_fun (this, &PlacesSearchBar::OnLayeredLayoutQueueDraw));
106
107 ubus_server_register_interest (ubus_server_get_default (), UBUS_PLACE_VIEW_HIDDEN,
108 (UBusCallback)PlacesSearchBar::OnPlacesClosed, this);
109
106}110}
107111
108PlacesSearchBar::~PlacesSearchBar ()112PlacesSearchBar::~PlacesSearchBar ()
@@ -360,6 +364,12 @@
360 g_free (font_desc);364 g_free (font_desc);
361}365}
362366
367void
368PlacesSearchBar::OnPlacesClosed (GVariant *variant, PlacesSearchBar *self)
369{
370 self->_combo->GetMenuPage ()->StopMenu ();
371}
372
363static void373static void
364draw_rounded_rect (cairo_t* cr,374draw_rounded_rect (cairo_t* cr,
365 double aspect,375 double aspect,
366376
=== modified file 'src/PlacesSearchBar.h'
--- src/PlacesSearchBar.h 2011-03-29 15:24:56 +0000
+++ src/PlacesSearchBar.h 2011-03-31 19:28:30 +0000
@@ -79,6 +79,7 @@
7979
80 static bool OnLiveSearchTimeout (PlacesSearchBar *self);80 static bool OnLiveSearchTimeout (PlacesSearchBar *self);
81 static void OnFontChanged (GObject *object, GParamSpec *pspec, PlacesSearchBar *self);81 static void OnFontChanged (GObject *object, GParamSpec *pspec, PlacesSearchBar *self);
82 static void OnPlacesClosed (GVariant *variant, PlacesSearchBar *self);
8283
83private:84private:
84 nux::AbstractPaintLayer *_bg_layer;85 nux::AbstractPaintLayer *_bg_layer;
8586
=== modified file 'src/PlacesView.cpp'
--- src/PlacesView.cpp 2011-03-24 01:47:55 +0000
+++ src/PlacesView.cpp 2011-03-31 19:28:30 +0000
@@ -179,6 +179,14 @@
179 return ret;179 return ret;
180}180}
181181
182static gboolean
183OnQueueDrawDrawDraw (PlacesView *self)
184{
185 self->QueueDraw ();
186
187 return FALSE;
188}
189
182void190void
183PlacesView::Draw (nux::GraphicsEngine& GfxContext, bool force_draw)191PlacesView::Draw (nux::GraphicsEngine& GfxContext, bool force_draw)
184{192{
@@ -232,6 +240,8 @@
232 GfxContext.Push2DWindow (GfxContext.GetWindowWidth (), GfxContext.GetWindowHeight ());240 GfxContext.Push2DWindow (GfxContext.GetWindowWidth (), GfxContext.GetWindowHeight ());
233 GfxContext.ApplyClippingRectangle ();241 GfxContext.ApplyClippingRectangle ();
234 }242 }
243
244 g_timeout_add (0, (GSourceFunc)OnQueueDrawDrawDraw, this);
235 }245 }
236246
237 if (_bg_blur_texture.IsValid () && paint_blur)247 if (_bg_blur_texture.IsValid () && paint_blur)
238248
=== modified file 'src/SimpleLauncherIcon.cpp'
--- src/SimpleLauncherIcon.cpp 2011-03-28 18:10:28 +0000
+++ src/SimpleLauncherIcon.cpp 2011-03-31 19:28:30 +0000
@@ -94,6 +94,7 @@
94 94
95 if (m_Icon)95 if (m_Icon)
96 m_Icon->UnReference ();96 m_Icon->UnReference ();
97 m_Icon = 0;
97 98
98 if (!m_IconName)99 if (!m_IconName)
99 return 0;100 return 0;
@@ -139,6 +140,6 @@
139 {140 {
140 self->m_Icon->UnReference ();141 self->m_Icon->UnReference ();
141 self->m_Icon = 0;142 self->m_Icon = 0;
143 self->needs_redraw.emit (self);
142 }144 }
143 self->needs_redraw.emit (self);
144}145}
145146
=== modified file 'src/StaticCairoText.cpp'
--- src/StaticCairoText.cpp 2011-03-23 17:51:31 +0000
+++ src/StaticCairoText.cpp 2011-03-31 19:28:30 +0000
@@ -35,7 +35,8 @@
35 View (NUX_FILE_LINE_PARAM),35 View (NUX_FILE_LINE_PARAM),
36 _fontstring (NULL),36 _fontstring (NULL),
37 _cairoGraphics (NULL),37 _cairoGraphics (NULL),
38 _texture2D (NULL)38 _texture2D (NULL),
39 _lines (-2)
3940
40{41{
41 _textColor = Color(1.0f, 1.0f, 1.0f, 1.0f);42 _textColor = Color(1.0f, 1.0f, 1.0f, 1.0f);
@@ -88,6 +89,14 @@
88 QueueDraw ();89 QueueDraw ();
89}90}
9091
92void
93StaticCairoText::SetLines (int lines)
94{
95 _lines = lines;
96 UpdateTexture ();
97 QueueDraw ();
98}
99
91void StaticCairoText::PreLayoutManagement ()100void StaticCairoText::PreLayoutManagement ()
92{101{
93 int textWidth = 0;102 int textWidth = 0;
@@ -325,7 +334,7 @@
325334
326335
327 pango_layout_set_markup (layout, _text.GetTCharPtr(), -1);336 pango_layout_set_markup (layout, _text.GetTCharPtr(), -1);
328 pango_layout_set_height (layout, -2);337 pango_layout_set_height (layout, _lines);
329 pango_layout_set_width (layout, maxwidth * PANGO_SCALE);338 pango_layout_set_width (layout, maxwidth * PANGO_SCALE);
330339
331 pangoCtx = pango_layout_get_context (layout); // is not ref'ed340 pangoCtx = pango_layout_get_context (layout); // is not ref'ed
@@ -406,7 +415,7 @@
406415
407 pango_layout_set_markup (layout, _text.GetTCharPtr(), -1);416 pango_layout_set_markup (layout, _text.GetTCharPtr(), -1);
408 pango_layout_set_width (layout, textWidth * PANGO_SCALE);417 pango_layout_set_width (layout, textWidth * PANGO_SCALE);
409 pango_layout_set_height (layout, -2);418 pango_layout_set_height (layout, _lines);
410 pangoCtx = pango_layout_get_context (layout); // is not ref'ed419 pangoCtx = pango_layout_get_context (layout); // is not ref'ed
411 pango_cairo_context_set_font_options (pangoCtx,420 pango_cairo_context_set_font_options (pangoCtx,
412 gdk_screen_get_font_options (screen));421 gdk_screen_get_font_options (screen));
413422
=== modified file 'src/StaticCairoText.h'
--- src/StaticCairoText.h 2011-03-20 18:15:16 +0000
+++ src/StaticCairoText.h 2011-03-31 19:28:30 +0000
@@ -86,6 +86,7 @@
86 void SetTextAlignment (AlignState state);86 void SetTextAlignment (AlignState state);
87 void SetTextVerticalAlignment (AlignState state);87 void SetTextVerticalAlignment (AlignState state);
88 void SetFont (const char *fontstring);88 void SetFont (const char *fontstring);
89 void SetLines (int lines);
8990
90 void GetTextExtents (int &width, int &height);91 void GetTextExtents (int &width, int &height);
9192
@@ -111,6 +112,8 @@
111 int _pre_layout_width;112 int _pre_layout_width;
112 int _pre_layout_height;113 int _pre_layout_height;
113114
115 int _lines;
116
114 void GetTextExtents (const TCHAR* font,117 void GetTextExtents (const TCHAR* font,
115 int& width,118 int& width,
116 int& height);119 int& height);
117120
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2011-03-24 02:07:30 +0000
+++ tests/CMakeLists.txt 2011-03-31 19:28:30 +0000
@@ -140,6 +140,8 @@
140 ../src/PlacesStyle.h140 ../src/PlacesStyle.h
141 ../src/PlacesTile.cpp141 ../src/PlacesTile.cpp
142 ../src/PlacesTile.h142 ../src/PlacesTile.h
143 ../src/PlacesHorizontalTile.cpp
144 ../src/PlacesHorizontalTile.h
143 ../src/PlacesSimpleTile.cpp145 ../src/PlacesSimpleTile.cpp
144 ../src/PlacesSimpleTile.h146 ../src/PlacesSimpleTile.h
145 ../src/TextureCache.h147 ../src/TextureCache.h