~om26er/ubuntu/oneiric/unity/sru-778256

« back to all changes in this revision

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

Update formatting to match style (as close as possible)

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
class IconLoader
29
29
{
30
30
public:
31
 
  typedef sigc::slot<void, const char *, guint, GdkPixbuf *> IconLoaderCallback;
32
 
 
33
 
  IconLoader ();
34
 
  ~IconLoader ();
35
 
 
36
 
 // DO NOT `delete` this...ever.
37
 
 static IconLoader * GetDefault ();
38
 
 
39
 
 void LoadFromIconName    (const char        *icon_name,
40
 
                           guint              size,
41
 
                           IconLoaderCallback slot);
42
 
 
43
 
 void LoadFromGIconString (const char        *gicon_string,
44
 
                           guint              size,
45
 
                           IconLoaderCallback slot);
46
 
 
47
 
 void LoadFromFilename    (const char        *filename,
48
 
                           guint              size,
49
 
                           IconLoaderCallback slot);
50
 
 
51
 
 void LoadFromURI         (const char        *uri,
52
 
                           guint              size,
53
 
                           IconLoaderCallback slot);
 
31
  typedef sigc::slot<void, const char*, guint, GdkPixbuf*> IconLoaderCallback;
 
32
 
 
33
  IconLoader();
 
34
  ~IconLoader();
 
35
 
 
36
// DO NOT `delete` this...ever.
 
37
  static IconLoader* GetDefault();
 
38
 
 
39
  void LoadFromIconName(const char*        icon_name,
 
40
                        guint              size,
 
41
                        IconLoaderCallback slot);
 
42
 
 
43
  void LoadFromGIconString(const char*        gicon_string,
 
44
                           guint              size,
 
45
                           IconLoaderCallback slot);
 
46
 
 
47
  void LoadFromFilename(const char*        filename,
 
48
                        guint              size,
 
49
                        IconLoaderCallback slot);
 
50
 
 
51
  void LoadFromURI(const char*        uri,
 
52
                   guint              size,
 
53
                   IconLoaderCallback slot);
54
54
private:
55
55
 
56
56
  enum IconLoaderRequestType
57
57
  {
58
 
    REQUEST_TYPE_ICON_NAME=0,
 
58
    REQUEST_TYPE_ICON_NAME = 0,
59
59
    REQUEST_TYPE_GICON_STRING,
60
60
    REQUEST_TYPE_URI,
61
61
  };
63
63
  struct IconLoaderTask
64
64
  {
65
65
    IconLoaderRequestType type;
66
 
    char                 *data;
 
66
    char*                 data;
67
67
    guint                 size;
68
 
    char                 *key;
 
68
    char*                 key;
69
69
    IconLoaderCallback    slot;
70
 
    IconLoader           *self;
 
70
    IconLoader*           self;
71
71
  };
72
72
 
73
73
 
74
 
  void   QueueTask (const char           *key,
75
 
                    const char           *data,
76
 
                    guint                 size,
77
 
                    IconLoaderCallback    slot,
78
 
                    IconLoaderRequestType type);
79
 
  char * Hash (const char *data, guint size);
80
 
  bool   CacheLookup (const char *key,
81
 
                      const char *data,
82
 
                      guint       size,
83
 
                      IconLoaderCallback slot);
84
 
  bool   ProcessTask (IconLoaderTask *task);
85
 
  bool   ProcessIconNameTask (IconLoaderTask *task);
86
 
  bool   ProcessGIconTask (IconLoaderTask *task);
87
 
  bool   ProcessURITask (IconLoaderTask *task);
88
 
  void   ProcessURITaskReady (IconLoaderTask *task, char *contents, gsize length);
89
 
  bool   Iteration ();
90
 
  void   FreeTask (IconLoaderTask *task);
91
 
 
92
 
  static bool Loop (IconLoader *self);
93
 
  static void LoadContentsReady (GObject *object, GAsyncResult *res, IconLoaderTask *task);
94
 
 
 
74
  void   QueueTask(const char*           key,
 
75
                   const char*           data,
 
76
                   guint                 size,
 
77
                   IconLoaderCallback    slot,
 
78
                   IconLoaderRequestType type);
 
79
  char* Hash(const char* data, guint size);
 
80
  bool   CacheLookup(const char* key,
 
81
                     const char* data,
 
82
                     guint       size,
 
83
                     IconLoaderCallback slot);
 
84
  bool   ProcessTask(IconLoaderTask* task);
 
85
  bool   ProcessIconNameTask(IconLoaderTask* task);
 
86
  bool   ProcessGIconTask(IconLoaderTask* task);
 
87
  bool   ProcessURITask(IconLoaderTask* task);
 
88
  void   ProcessURITaskReady(IconLoaderTask* task, char* contents, gsize length);
 
89
  bool   Iteration();
 
90
  void   FreeTask(IconLoaderTask* task);
 
91
 
 
92
  static bool Loop(IconLoader* self);
 
93
  static void LoadContentsReady(GObject* object, GAsyncResult* res, IconLoaderTask* task);
 
94
 
95
95
private:
96
96
  bool _no_load;
97
97
 
98
 
  std::map<std::string, GdkPixbuf *> _cache;
99
 
  GQueue       *_tasks;
 
98
  std::map<std::string, GdkPixbuf*> _cache;
 
99
  GQueue*       _tasks;
100
100
  guint         _idle_id;
101
 
  GtkIconTheme *_theme;
 
101
  GtkIconTheme* _theme;
102
102
  gint64        _idle_start_time;
103
103
};
104
104