Fix crash with type checking for GObject arguments

Ensure we have a valid GObject before attempting to call g_type_is_a.
Swap conditional blocks to make if condition more readable.

https://bugzilla.gnome.org/show_bug.cgi?id=727604