After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 567789 - Make EvDocumentInfo and friends GTypes
Make EvDocumentInfo and friends GTypes
Status: RESOLVED FIXED
Product: evince
Classification: Core
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: Evince Maintainers
Evince Maintainers
Depends on:
Blocks:
 
 
Reported: 2009-01-14 19:39 UTC by Tomeu Vizoso
Modified: 2009-01-18 21:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
first try (9.66 KB, patch)
2009-01-14 19:40 UTC, Tomeu Vizoso
none Details | Review
use glib-mkenums (4.12 KB, patch)
2009-01-15 19:06 UTC, Tomeu Vizoso
needs-work Details | Review
use glib-mkenums and templates (8.24 KB, patch)
2009-01-18 18:43 UTC, Tomeu Vizoso
none Details | Review
revised patch after code review in irc (7.21 KB, patch)
2009-01-18 19:20 UTC, Tomeu Vizoso
committed Details | Review

Description Tomeu Vizoso 2009-01-14 19:39:48 UTC
Need it to be a GType so it can be used by language bindings like python.
Comment 1 Tomeu Vizoso 2009-01-14 19:40:39 UTC
Created attachment 126448 [details] [review]
first try
Comment 2 Christian Persch 2009-01-15 13:48:59 UTC
+	static GType type = 0;
+
+	if (G_UNLIKELY (type == 0)) {

Should use the standard pattern for get_type functions, which is using g_once_*.

+	if (info->title)
+		copy->title = g_strdup (info->title);

g_strdup is NULL-safe.

Why are you hardcoding the get_type functions for the enum/flags types, instead of using glib-mkenums for this?
Comment 3 Tomeu Vizoso 2009-01-15 19:06:42 UTC
Created attachment 126529 [details] [review]
use glib-mkenums
Comment 4 Tomeu Vizoso 2009-01-18 15:29:33 UTC
Would you prefer to use template files instead of putting the templates in the Makefile?
Comment 5 Carlos Garcia Campos 2009-01-18 16:03:00 UTC
(In reply to comment #4)
> Would you prefer to use template files instead of putting the templates in the
> Makefile?
> 

yes please, like we already do in libview.
Comment 6 Tomeu Vizoso 2009-01-18 18:43:40 UTC
Created attachment 126703 [details] [review]
use glib-mkenums and templates
Comment 7 Tomeu Vizoso 2009-01-18 19:20:35 UTC
Created attachment 126708 [details] [review]
revised patch after code review in irc
Comment 8 Carlos Garcia Campos 2009-01-18 19:44:04 UTC
Applied to svn trunk (r3356). Thanks. 
Comment 9 Christian Persch 2009-01-18 19:53:31 UTC
It's still using the

+	static GType type = 0;
+	if (type == 0)

get_type for the boxed type, not g_once_*().
Comment 10 Carlos Garcia Campos 2009-01-18 21:24:48 UTC
yes, it's what we are using for all the interfaces and what gtk+ does for boxed types too. What's exactly wrong?
Comment 11 Christian Persch 2009-01-18 21:33:58 UTC
Oh, I see. Well, it's not threadsafe. Also for consistency's sake, I think evince should use the g_once_* thing (like G_DEFINE_TYPE does). I'll file a separate bug then.