Merge lp:~rainct/libzeitgeist/log_get_default into lp:libzeitgeist

Proposed by Siegfried Gevatter
Status: Merged
Approved by: Mikkel Kamstrup Erlandsen
Approved revision: 220
Merged at revision: 220
Proposed branch: lp:~rainct/libzeitgeist/log_get_default
Merge into: lp:libzeitgeist
Prerequisite: lp:~rainct/libzeitgeist/776651-doc
Diff against target: 91 lines (+38/-0)
3 files modified
src/zeitgeist-log.c (+26/-0)
src/zeitgeist-log.h (+2/-0)
tests/test-log.c (+10/-0)
To merge this branch: bzr merge lp:~rainct/libzeitgeist/log_get_default
Reviewer Review Type Date Requested Status
Mikkel Kamstrup Erlandsen Approve
Review via email: mp+91284@code.launchpad.net
To post a comment you must log in.
220. By Siegfried Gevatter

Give stuff the right name, even

Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Just perfect!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/zeitgeist-log.c'
--- src/zeitgeist-log.c 2012-01-30 12:26:04 +0000
+++ src/zeitgeist-log.c 2012-02-02 15:11:19 +0000
@@ -120,6 +120,8 @@
120 GAsyncResult *res,120 GAsyncResult *res,
121 gpointer user_data);121 gpointer user_data);
122122
123static ZeitgeistLog *zeitgeist_log_singleton = NULL;
124
123static void125static void
124zeitgeist_log_init (ZeitgeistLog *self)126zeitgeist_log_init (ZeitgeistLog *self)
125{127{
@@ -310,6 +312,10 @@
310 * until the connection is ready - at which point you will get a notify signal312 * until the connection is ready - at which point you will get a notify signal
311 * on the #ZeitgeistLog:connected property.313 * on the #ZeitgeistLog:connected property.
312 *314 *
315 * It isn't recommended to call this function more than once. If you need to
316 * access #ZeitgeistLog from different parts of your codebase, consider using
317 * zeitgeist_log_get_default() instead.
318 *
313 * Returns: A reference to a newly allocated log.319 * Returns: A reference to a newly allocated log.
314 */320 */
315ZeitgeistLog*321ZeitgeistLog*
@@ -324,6 +330,26 @@
324}330}
325331
326/**332/**
333 * zeitgeist_log_get_default:
334 * Get a unique instance of #ZeitgeistLog, that you can share in your
335 * application without caring about memory management.
336 *
337 * See zeitgeist_log_new() for more information.
338 *
339 * Returns: (transfer none): A unique #ZeitgeistLog. Do not ref or unref it.
340 *
341 * Since: 0.3.14
342 */
343ZeitgeistLog*
344zeitgeist_log_get_default (void)
345{
346 if (G_UNLIKELY (!zeitgeist_log_singleton))
347 zeitgeist_log_singleton = zeitgeist_log_new ();
348
349 return zeitgeist_log_singleton;
350}
351
352/**
327 * zeitgeist_log_insert_events:353 * zeitgeist_log_insert_events:
328 * @self: The log logging the events354 * @self: The log logging the events
329 * @cancellable: To cancel the operation or %NULL355 * @cancellable: To cancel the operation or %NULL
330356
=== modified file 'src/zeitgeist-log.h'
--- src/zeitgeist-log.h 2011-03-07 14:19:39 +0000
+++ src/zeitgeist-log.h 2012-02-02 15:11:19 +0000
@@ -60,6 +60,8 @@
6060
61ZeitgeistLog* zeitgeist_log_new (void);61ZeitgeistLog* zeitgeist_log_new (void);
6262
63ZeitgeistLog* zeitgeist_log_get_default (void);
64
63void zeitgeist_log_insert_events (ZeitgeistLog *self,65void zeitgeist_log_insert_events (ZeitgeistLog *self,
64 GCancellable *cancellable,66 GCancellable *cancellable,
65 GAsyncReadyCallback callback,67 GAsyncReadyCallback callback,
6668
=== modified file 'tests/test-log.c'
--- tests/test-log.c 2010-06-10 08:39:30 +0000
+++ tests/test-log.c 2012-02-02 15:11:19 +0000
@@ -198,6 +198,14 @@
198 g_main_loop_run (fix->mainloop);198 g_main_loop_run (fix->mainloop);
199}199}
200200
201static void
202test_get_default (Fixture *fix, gconstpointer data) {
203 ZeitgeistLog *zeitgeist_log1, *zeitgeist_log2;
204 zeitgeist_log1 = zeitgeist_log_get_default ();
205 zeitgeist_log2 = zeitgeist_log_get_default ();
206 g_assert (zeitgeist_log1 == zeitgeist_log2);
207}
208
201int209int
202main (int argc,210main (int argc,
203 char *argv[])211 char *argv[])
@@ -207,6 +215,8 @@
207 215
208 g_test_add ("/Zeitgeist/Log/InsertGetDelete", Fixture, NULL,216 g_test_add ("/Zeitgeist/Log/InsertGetDelete", Fixture, NULL,
209 setup, test_insert_get_delete, teardown);217 setup, test_insert_get_delete, teardown);
218 g_test_add ("/Zeitgeist/Log/GetDefault", Fixture, NULL,
219 NULL, test_get_default, NULL);
210 220
211 return g_test_run();221 return g_test_run();
212}222}

Subscribers

People subscribed via source and target branches