~ubuntu-branches/ubuntu/natty/unity-2d/natty-updates

« back to all changes in this revision

Viewing changes to libunity-2d-private/src/gscopedpointer.h

  • Committer: Bazaar Package Importer
  • Author(s): Oliver Grawert, Oliver Grawert, Aurélien Gâteau
  • Date: 2011-04-08 16:03:10 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20110408160310-yth7qb9kbgabkqk0
Tags: 3.8.2-0ubuntu1
[ Oliver Grawert ]
* New upstream bugfix release
 - (LP: #632526)  Dash elipsizes file and application names too soon, making them
   unreadable
 - (LP: #669926) [launcher] Web favorites support
 - (LP: #708479) Dash view should use "Prefferred Applications" icons where
   appropriate
 - (LP: #718686) [dash] Group of results sometimes badly positioned
 - (LP: #727483) unity-2d-panel crashed with SIGSEGV in g_return_if_fail_warning()
 - (LP: #731449) [launcher] Dragging a tile at the top of the launcher while
   autoscrolling makes autoscroll wrong afterwards
 - (LP: #736097) [dash] home screen misses icons for applications that are not
   installed
 - (LP: #744999) [launcher] launchers are truncated when too many items to fit
   onscreen
 - (LP: #745077) [spread] clicking launcher with open windows not working correctly
   across workspaces
 - (LP: #745237) [dash] search field default string not translated
 - (LP: #746693) [launcher] .places messages not i18nized
 - (LP: #747836) [dash] Banshee no longer works from the dash home page in 3.8.2
 - (LP: #750753) [dash] showing/hiding places causing graphical corruption
 - (LP: #670608) [dash] Home screen customization should be easy
 - (LP: #683084) Global menu doesn't work well with more than one screen
 - (LP: #714646) [launcher] icons jagged edges during animation
 - (LP: #717744) [panel] inactive menus are clickable
 - (LP: #729002) First four items in Dash begin "Find" "Find" "Find" "Find"
 - (LP: #745758) [spread] super+s should toggle the workspace switcher
 - (LP: #751284) [launcher] Escaping of title broken with webfavorites
 - (LP: #751325) [panel] circle of friends button icon needs to be updated to match
   Unity's
 - (LP: #697816) [launcher] if an urgent window is available then the spread should
   not be activated
 - (LP: #729478) [launcher] Clicking middle mouse button should launch another
   instance of application
 - (LP: #750244) [launcher] Newly installed lenses don’t appear
 - (LP: #752948) Home's "Shortcuts" not i18n/l10n

[ Aurélien Gâteau ]
* Include .mo files in unity-2d package (LP: #751425)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of unity-2d
 
3
 *
 
4
 * Copyright 2011 Canonical Ltd.
 
5
 *
 
6
 * Authors:
 
7
 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
 
8
 *
 
9
 * License: GPL v3
 
10
 */
 
11
#ifndef GSCOPEDPOINTER_H
 
12
#define GSCOPEDPOINTER_H
 
13
 
 
14
// Local
 
15
 
 
16
// Qt
 
17
#include <QScopedPointer>
 
18
 
 
19
// GLib
 
20
#include <glib-object.h>
 
21
 
 
22
/**
 
23
 * Helper class for GScopedPointer
 
24
 */
 
25
template <class T, void (*cleanup_fcn)(T*)>
 
26
class GScopedPointerDeleter
 
27
{
 
28
public:
 
29
    static void cleanup(T* ptr)
 
30
    {
 
31
        if (ptr) {
 
32
            cleanup_fcn(ptr);
 
33
        }
 
34
    }
 
35
};
 
36
 
 
37
/**
 
38
 * A GScopedPointer works like a QScopedPointer, except the cleanup static
 
39
 * method is replaced with a cleanup function, making it useful to handle C
 
40
 * structs whose cleanup function prototype is "void cleanup(T*)"
 
41
 *
 
42
 * Best way to use it is to define a typedef for your C struct, like this:
 
43
 *
 
44
 * typedef GScopedPointer<Foo, foo_free> GFooPointer;
 
45
 */
 
46
template <class T, void (*cleanup)(T*)>
 
47
class GScopedPointer : public QScopedPointer<T, GScopedPointerDeleter<T, cleanup> >
 
48
{
 
49
public:
 
50
    GScopedPointer(T* ptr = 0)
 
51
    : QScopedPointer<T, GScopedPointerDeleter<T, cleanup> >(ptr)
 
52
    {}
 
53
};
 
54
 
 
55
 
 
56
/**
 
57
 * Helper class for GObjectScopedPointer
 
58
 */
 
59
template <class T, void (*cleanup_fcn)(gpointer)>
 
60
class GObjectScopedPointerDeleter
 
61
{
 
62
public:
 
63
    static void cleanup(T* ptr)
 
64
    {
 
65
        if (ptr) {
 
66
            cleanup_fcn(ptr);
 
67
        }
 
68
    }
 
69
};
 
70
 
 
71
/**
 
72
 * A GObjectScopedPointer is similar to a GScopedPointer. The only difference
 
73
 * is its cleanup function signature is "void cleanup(gpointer)" and defaults to
 
74
 * g_object_unref(), making it useful for GObject-based classes.
 
75
 *
 
76
 * You can use it directly like this:
 
77
 *
 
78
 * GObjectScopedPointer<GFoo> foo;
 
79
 *
 
80
 * Or define a typedef for your class:
 
81
 *
 
82
 * typedef GObjectScopedPointer<GFoo> GFooPointer;
 
83
 *
 
84
 * Note: GObjectScopedPointer does *not* call gobject_ref() when assigned a
 
85
 * pointer.
 
86
 */
 
87
template <class T, void (*cleanup)(gpointer) = g_object_unref>
 
88
class GObjectScopedPointer : public QScopedPointer<T, GObjectScopedPointerDeleter<T, cleanup> >
 
89
{
 
90
public:
 
91
    GObjectScopedPointer(T* ptr = 0)
 
92
    : QScopedPointer<T, GObjectScopedPointerDeleter<T, cleanup> >(ptr)
 
93
    {}
 
94
};
 
95
 
 
96
// A Generic GObject pointer
 
97
typedef GObjectScopedPointer<GObject> GObjectPointer;
 
98
 
 
99
// Take advantage of the cleanup signature of GObjectScopedPointer to define
 
100
// a GCharPointer
 
101
typedef GObjectScopedPointer<gchar, g_free> GCharPointer;
 
102
 
 
103
#endif /* GSCOPEDPOINTER_H */