Commit Graph

15475 Commits

Author SHA1 Message Date
Ryan Lortie
8ea414c8c6 G_DECLARE_*_TYPE: add auto cleanup support
Automatically add support for the new cleanup macros to the type
declaration macros.

This is an API break because now your parent class needs to support
cleanup if you want to use G_DECLARE_*_TYPE.  These macros are only 1
day old, however, so that's probably not a big problem (and we are
already busy adding the macros all over GLib and Gtk+).

https://bugzilla.gnome.org/show_bug.cgi?id=743640
2015-01-30 16:52:36 +01:00
Ryan Lortie
3d5de34def gobject: add support for g_auto() and g_autoptr()
Add support to libgobject types for the new cleanup macros.

https://bugzilla.gnome.org/show_bug.cgi?id=743640
2015-01-30 16:52:36 +01:00
Ryan Lortie
663834671d glib: add support for g_auto() and g_autoptr()
Add support to the libglib types for the new cleanup macros.

https://bugzilla.gnome.org/show_bug.cgi?id=743640
2015-01-30 16:52:36 +01:00
Ryan Lortie
2596919c58 macros: add support for GNUC cleanup __attribute__
Add g_auto() and g_autoptr() as helpers for declaring variables with
automatic cleanup.

Add some macros to help types define cleanup functions for themselves.

Going forward it will be an expectation that people use this macro when
creating a new type, even if they do not intend to use the auto-cleanup
functionality for themselves.

These new macros only work on GCC and clang, which is why we resisted
adding them for so long.  There exist many people who are only
interested in writing programs for these compilers, however, and a
similar API in libgsystem has proven to be extremely popular, so let's
expose this functionality to an even wider audience.

We ignore deprecation warnings when emitting the free functions, which
seems suspicious.  The reason that we do this is not because we want to
call deprecated functions, but just the opposite: sometimes the free
function will be an _unref() function that is only AVAILABLE_IN newer
versions, and these warnings are also implemented as deprecation
warnings.

https://bugzilla.gnome.org/show_bug.cgi?id=743640
2015-01-30 16:49:53 +01:00
Ryan Lortie
b5e1ea6fee DECLARE_TYPE: ignore deprecations in inlines
Prevent complaints about deprecations in the inline functions emitted by
the new G_DECLARE_*_TYPE macros.
2015-01-30 16:49:53 +01:00
Ryan Lortie
9d0389b3b5 G_DECLARE_FINAL_TYPE: trivial fix in docs comment
https://bugzilla.gnome.org/show_bug.cgi?id=743640
2015-01-30 16:49:53 +01:00
Ryan Lortie
93982d4a16 giotypefuncs test: tweak _get_type() regexp
Make sure that we only match the _get_type() function name by
restricting the regexp to matching [A-Za-z0-9_].  We were matching on .*
before which means that if we had two _get_type() functions appearing on
a single line then we would get everything in between them included (by
the default rule of '*' being greedy).

This affected G_DECLARE_*_TYPE which puts several uses of _get_type()
into a single line.
2015-01-30 15:30:02 +01:00
Lars Uebernickel
b69beff426 Add GListModel
GListModel is an interface that represents a dynamic list of GObjects.

Also add GListStore, a simple implementation of GListModel that stores
all objects in memory, using a GSequence.

https://bugzilla.gnome.org/show_bug.cgi?id=729351
2015-01-30 15:08:57 +01:00
Lars Uebernickel
6d55189d8c gsettings: add g_settings_schema_list_children
https://bugzilla.gnome.org/show_bug.cgi?id=743517
2015-01-28 18:09:28 +00:00
Lars Uebernickel
d95bb1f08b gsettings: add g_settings_schema_key_get_name
https://bugzilla.gnome.org/show_bug.cgi?id=743517
2015-01-28 18:09:28 +00:00
Christian Hergert
f3c604d273 G_DECLARE_DERIVED_TYPE: allow forward declarations
This allows multiple declarations such as:

 typedef struct _Foo Foo;

as is needed when you have systems with circular referencing.

https://bugzilla.gnome.org/show_bug.cgi?id=743596
2015-01-28 13:22:23 +00:00
Dan Winship
e8d3f29300 gcredentialsprivate: clarify the USE_FREEBSD_CMSGCRED users
Add comments clarifying what the three non-FreeBSD platforms using
G_CREDENTIALS_USE_FREEBSD_CMSGCRED are.
2015-01-27 07:38:31 -05:00
Peeter Must
4c54b9fe31 gcredentials: Add support for DragonFly
https://bugzilla.gnome.org/show_bug.cgi?id=743508
2015-01-27 07:31:24 -05:00
Ryan Lortie
3b4cb28e17 gtype: add type declaration macros for headers
Add G_DECLARE_DERIVABLE_TYPE() and G_DECLARE_FINAL_TYPE() to allow
skipping almost all of the typical GObject boilerplate code.

These macros make some assumptions about GObject best practice that mean
that they may not be usable with older classes that have to preserve
API/ABI compatibility with a time before these practices existed.

https://bugzilla.gnome.org/show_bug.cgi?id=389585
2015-01-27 11:07:52 +00:00
Chun-wei Fan
e07cc89dee glib-sections.txt: Add g_win32_check_windows_version()
https://bugzilla.gnome.org/show_bug.cgi?id=741895
2015-01-27 12:17:25 +08:00
Chun-wei Fan
bcbf80c355 gwin32: Add g_win32_check_windows_version() API
This adds a public API where one can use to see whether the running version
of Windows where the code is run is at least the specified version, service
pack level, and the type (non-server, server, any) of the running Windows
OS.

This API is done as:
-GetVersion()/GetVersionEx() changed in the way they work since Windows 8.1
 [1][2], so a newer mechanism to check the version of the running Windows
 operating system is needed.  MSDN also states that GetVersion() might be
 further changed or removed after Windows 8.1.  This provides a wrapper for
 VerfyVersionInfo() as well in GLib for most cases, which was recommended
 in place of g_win32_get_windows_version() for more detailed Windows
 version checking.
-Provides an OS-level functionality check, for those that we don't need to
 venture into GetProcAddress(), and also to determine system API behavior
 changes due to differences in OS versions.

Also added a note for the g_win32_get_windows_version() API that since the
behavior of GetVersion() which it uses, is changed since Windows 8.1, users
of the API should be aware.

[1]:
http://msdn.microsoft.com/zh-tw/library/windows/desktop/ms724451%28v=vs.85%29.aspx
[2]:
http://msdn.microsoft.com/zh-tw/library/windows/desktop/ms724451%28v=vs.85%29.aspx

https://bugzilla.gnome.org/show_bug.cgi?id=741895
2015-01-27 12:17:14 +08:00
Cosimo Cecchi
be2d9b4f58 GSimpleAction: add g_simple_action_set_state_hint
Currently the only way to set a state hint on an action is through a
subclass; add a g_simple_action_set_state_hint() method so that this
becomes easier for clients that already use GSimpleAction.

https://bugzilla.gnome.org/show_bug.cgi?id=743521
2015-01-26 12:06:24 +00:00
Ilya Konstantinov
2a0c18041b gthread: add thread name support on Mac OS
https://bugzilla.gnome.org/show_bug.cgi?id=741807
2015-01-26 09:06:13 +00:00
Philip Withnall
1cf7f5a240 gobject: Fix a typo in a documentation comment 2015-01-25 17:09:35 +00:00
Philip Withnall
4462cd30bc gthread: Fix a typo in a documentation comment 2015-01-25 17:09:24 +00:00
Philip Withnall
92041f4b3b gstrfuncs: Document that g_ascii_dtostr() writes a nul terminator
And g_ascii_formatd().

Reviewed-by: Ryan Lortie <desrt@desrt.ca>
2015-01-25 16:22:43 +00:00
Chun-wei Fan
ef09373e03 gio/Makefile.am: Fix MSVC Project Generation
We need to filter out gnetworkmonitornm.c in the MSVC Projects, as that is
UNIX-only code.
2015-01-21 14:28:47 +08:00
Ryan Lortie
29307b4e41 bump version 2015-01-20 01:38:13 -05:00
Ryan Lortie
95ea50d73c GLib 2.43.3 2015-01-20 00:05:28 -05:00
Philip Withnall
11a846b6bf gtestutils: Add an example of using test fixtures
Add a simple example of a test suite with two unit tests both using the
same fixture.

https://bugzilla.gnome.org/show_bug.cgi?id=743014
2015-01-18 23:04:05 +00:00
Inaki Larranaga Murgoitio
ee245b57ff Updated Basque language 2015-01-17 17:14:46 +01:00
Ignacio Casal Quinteiro
cf03e82478 gsocket: always try before waiting for condition
When implementing blocking operations on top of
nonblocking sockets we should always first try to
perform the operation and then if needed handle
EAGAIN and wait with g_socket_wait_condition.
This is an optimization since we avoid calling
wait condition when it is not needed, but most
importantly this fixes hangs on win32 where some
events (in particular FD_WRITE) are only emitted
after the operation fails with EWOULDBLOCK.

https://bugzilla.gnome.org/show_bug.cgi?id=732439
https://bugzilla.gnome.org/show_bug.cgi?id=741707
2015-01-17 15:04:25 +01:00
Paolo Borelli
4f4714285d gsocket: add a testcase that shows a hang on win32
Add a unit test that checks g_socket_new_from_fd by creating
a gsocket, obtaining its fd, duplicating the fd and then creating
a gsocket from the new fd. This shows a hang on win32 since the
gsocket created from the fd never receives the FD_WRITE event
because we wait for the condition without first trying to write
and windows signals the condition only after a EWOULDBLOCK error.

https://bugzilla.gnome.org/show_bug.cgi?id=741707
2015-01-17 15:04:25 +01:00
Philip Withnall
2c5076cd58 gtestutils: Add links to gtester and gtester-report documentation
Link some existing text to make cross-referencing a little easier.
2015-01-16 09:22:21 +00:00
Philip Withnall
056f50ce94 gtestutils: Fix a typo in the g_test_add() documentation 2015-01-16 09:18:41 +00:00
Philip Withnall
7dd7c04148 gtestutils: Clarify that test fixtures are allocated by GLib
Make it a little clearer that the user’s fixture setup and teardown
functions don’t have to do the allocation or freeing.
2015-01-16 09:15:07 +00:00
Philip Withnall
123bd7aecf gtestutils: Fix a typo in the g_test_run() documentation 2015-01-16 09:15:07 +00:00
Philip Withnall
9114923db2 ggettext: Include an example of setlocale() and friends in the i18n docs
Include an example main() function, and include a link to the gettext
manual’s section on integrating gettext with build systems.

That should work as a complete reference for how to add i18n support to
an application.

https://bugzilla.gnome.org/show_bug.cgi?id=742972
2015-01-15 14:22:25 +00:00
Paolo Borelli
7a8ef00aae Avoid warning when using G_STMT_END macro with MSVC
Workaround found on
http://cnicholson.net/2009/03/stupid-c-tricks-dowhile0-and-c4127/

https://bugzilla.gnome.org/show_bug.cgi?id=742851
2015-01-14 16:21:00 +01:00
Paolo Borelli
432476355b Use G_STMT_START/END in gslice.h 2015-01-14 16:21:00 +01:00
Paolo Borelli
be0c9e507a Use G_STMT_START/END in gtestutils 2015-01-14 16:21:00 +01:00
Philip Withnall
70e2630f5a gsettings: Fix a typo in the GSettings documentation
https://bugzilla.gnome.org/show_bug.cgi?id=741788
2015-01-14 10:53:04 +00:00
Matthias Clasen
b1e5b0e733 Bump version
So that early adopters of new api have a version to target.
2015-01-13 16:54:59 -05:00
Iain Lane
f7be461601 gnetworkmonitornm: Check if network-manager is running
We were asking for properties on NM's dbus interface, but if NM is not
running then there won't be any. Check if the name has an owner before
doing anything to it.

https://bugzilla.gnome.org/show_bug.cgi?id=741653
2015-01-13 12:11:06 +01:00
Ryan Lortie
84a1efeabd configure.ac: reject 'universal' builds
AC_C_BIGENDIAN can return 'universal' as the result in the case that we
are trying to do a universal build on Mac OS.  This has to be opted into
explicitly by using multiple -arch CFLAGS.

Previously, we detected this result and fell back to doing our own check
based on the endianness of the build machine, hardcoding that.  This
means that universal builds might successfully build, but the binaries
would never actually run correctly on the 'opposite' arch.

This check was added because of a bug in the intial implementation of
this detection in autoconf, which was inappropriately identifying
non-macos compilers as 'universal'.  That was hitting ppc64 systems.
See https://bugzilla.redhat.com/show_bug.cgi?id=449944 for more info.

Commit b0e687ef42e21b1eb7af18c4eaebcd41b0bd5632 in autoconf ("Limit
AC_C_BIGENDIAN univeral checks to Mac OS X") solved this issue in 2008,
so let's remove our workaround.  For good measure, if we detect
"universal" in the result, error out.

https://bugzilla.gnome.org/show_bug.cgi?id=742548
2015-01-10 18:00:02 -05:00
Rafael Ferreira
12b5eff6dc Updated Brazilian Portuguese translation 2015-01-09 01:49:13 +00:00
Chun-wei Fan
1632d5716e Win32: Update Pre-configured Config Headers
Update config.h.win32.in and glibconfig.h.win32.in so that they will be
in-line with the ones that are produced with configure.ac, for use on
Windows builds.

Thanks to Philip Withnall for pointing out the changes needed to update
glibconfig.h.win32.in in bug 727829.
2015-01-07 09:59:47 +08:00
Timm Bäder
327d35ed41 gnetworkmonitornm: Prevent crash
g_dbus_proxy_get_cached_property_names can return NULL if there are no
cached properties, so don't try to access them in that case.
2015-01-05 11:51:46 +01:00
TingPing
aa4e2d4dc3 Fix GContentType usage
https://bugzilla.gnome.org/show_bug.cgi?id=734946
2015-01-04 22:09:37 -05:00
Matthias Clasen
48293bb47d Fix a typo 2014-12-23 19:49:41 -05:00
Erick Pérez Castellanos
8344bf1179 Fix document typo
This one was making syntax highlighting fail.
2014-12-22 11:02:08 -05:00
Matthias Clasen
30abc73c1a Silence the build some more 2014-12-20 21:32:53 -05:00
Thomas Haller
c447bc7f93 gobject: don't use G_STRLOC in G_OBJECT_WARN_INVALID_PSPEC() macro
Using G_STRLOC ends up embedding unique strings of the form
__FILE__:__LINE__ in the compiled binary. We can avoid these
by passing __FILE__ and __LINE__ separately when constructing
the warning text.
This probably reduces the size of the binary as __FILE__ is
likely already contained as string otherwise.

Note that for GCC 2.x this changes behavior because G_STRLOC
also contained __PRETTY_FUNCTION__.

https://bugzilla.gnome.org/show_bug.cgi?id=741654
2014-12-18 15:02:16 +01:00
Philip Withnall
d951db4236 gobject: Add g_set_object() convenience function to set GObject pointers
Along the same lines as g_clear_object(), g_set_object() is a
convenience function to update a GObject pointer, handling reference
counting transparently and correctly.

Specifically, it handles the case where a pointer is set to its current
value. If handled naïvely, that could result in the object instance
being finalised. In the following code, that happens when
(my_obj == new_value) and the object has a single reference:
    g_clear_object (&my_obj);
    my_obj = g_object_ref (new_value);

It also simplifies boilerplate code such as set_property()
implementations, which are otherwise long and boring.

Test cases included.

https://bugzilla.gnome.org/show_bug.cgi?id=741589
2014-12-18 11:32:56 +00:00
Philip Chimento
4f3ab40c04 gfile: Explain nonobvious use of my_error
In g_file_make_directory_with_parents(), the my_error variable is used
for several different purposes throughout the whole function, not all of
which are obvious. This explains the situation with some comments.

https://bugzilla.gnome.org/show_bug.cgi?id=719455
2014-12-18 02:02:53 -05:00