Gtk2

 view release on metacpan or  search on metacpan

xs/Gtk2.xs  view on Meta::CPAN

	    (gtk_major_version == GTK_MAJOR_VERSION && 
	     gtk_minor_version == GTK_MINOR_VERSION &&
	     ((int)gtk_micro_version) < GTK_MICRO_VERSION))
		warn ("*** This build of Gtk2 was compiled with gtk+ %d.%d.%d,"
		      " but is currently running with %d.%d.%d, which is too"
		      " old.  We'll continue, but expect problems!\n",
		      GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION,
		      gtk_major_version, gtk_minor_version, gtk_micro_version);
	}

#############################################################################
#############################################################################

=for object Gtk2::version Library Version Information
=cut

=head1 SYNOPSIS

  use Gtk2 '1.023';  # require at least version 1.023 of the bindings

  if ($Gtk2::VERSION >= 1.040 and Gtk2->CHECK_VERSION (2, 4, 0)) {
     # the GtkFileChooser, new in gtk+ 2.4.0 and first supported in
     # Gtk2-Perl at 1.040, is available
  } else {
     # GtkFileChooser is not available, fall back to GtkFileSelection
  }

=head1 DESCRIPTION

Since the Gtk2 Perl module is a bridge to an external library with its own
versions and API revisions, we have three different versions available for
inspection.  Which one you need to use at which time depends entirely on
the situation.  Gtk2 uses the same scheme as Glib and the underlying gtk+
C library; that is, the standard
C<$Gtk2::VERSION> for the version of the bindings, all-caps
(MAJOR|MINOR|MICRO)_VERSION functions for the bound version, and
lower-case (major|minor|micro)_version functions for the runtime version.
See L<Glib::version> and
L<http://developer.gnome.org/doc/API/2.0/gtk/gtk-Feature-Test-Macros.html>
for more information.

Note also that gtk_check_version() and GTK_CHECK_VERSION() have different
semantics in C, and we have preserved those faithfully.

=cut

=for see_also Glib::version
=cut

  # we have no use for these in perl.
 ##GTKMAIN_C_VAR const guint gtk_binary_age;
 ##GTKMAIN_C_VAR const guint gtk_interface_age;

=for apidoc
=for signature (major, minor, micro) = Gtk2->get_version_info
Shorthand to fetch as a list the gtk+ version against which Gtk2 is linked.
See C<Gtk2::major_version>, etc.
=cut
void
gtk_get_version_info (class)
    PPCODE:
	EXTEND(SP,3);
	PUSHs(sv_2mortal(newSViv(gtk_major_version)));
	PUSHs(sv_2mortal(newSViv(gtk_minor_version)));
	PUSHs(sv_2mortal(newSViv(gtk_micro_version)));
	PERL_UNUSED_VAR (ax);

=for apidoc
Returns undef if the version of gtk+ currently in use is compatible with the
given version, otherwise returns a string describing the mismatch.  Note that
this is not the same logic as C<Gtk2::CHECK_VERSION>.  This check is not
terribly reliable, and should not be used to test for availability of widgets
or functions in the Gtk2 module --- use C<Gtk2::CHECK_VERSION> for that.
See L<Glib::version> for a more detailed description of when you'd want to
do a runtime-version test.
=cut
gchar * 
gtk_check_version (class, required_major, required_minor, required_micro)
	guint   required_major
	guint   required_minor
	guint   required_micro
    CODE:
	RETVAL = (gchar *) gtk_check_version (required_major, required_minor, required_micro);
    OUTPUT:
	RETVAL

=for apidoc Gtk2::MAJOR_VERSION __function__
The major version of the gtk+ library against which Gtk2 was compiled.
Equivalent to gtk+'s GTK_MAJOR_VERSION.
=cut

=for apidoc Gtk2::MINOR_VERSION __function__
The minor version of the gtk+ library against which Gtk2 was compiled.
Equivalent to gtk+'s GTK_MINOR_VERSION.
=cut

=for apidoc Gtk2::MICRO_VERSION __function__
The micro version of the gtk+ library against which Gtk2 was compiled.
Equivalent to gtk+'s GTK_MICRO_VERSION.
=cut

=for apidoc Gtk2::major_version __function__
The major version of the gtk+ library current in use at runtime.
Equivalent to gtk+'s global variable gtk_major_version.
=cut

=for apidoc Gtk2::minor_version __function__
The minor version of the gtk+ library current in use at runtime.
Equivalent to gtk+'s global variable gtk_minor_version.
=cut

=for apidoc Gtk2::micro_version __function__
The micro version of the gtk+ library current in use at runtime.
Equivalent to gtk+'s global variable gtk_micro_version.
=cut

guint
MAJOR_VERSION ()
    ALIAS:
	Gtk2::MINOR_VERSION = 1
	Gtk2::MICRO_VERSION = 2
	Gtk2::major_version = 3
	Gtk2::minor_version = 4
	Gtk2::micro_version = 5
    CODE:
	switch (ix)
	{
	case 0: RETVAL = GTK_MAJOR_VERSION; break;
	case 1: RETVAL = GTK_MINOR_VERSION; break;
	case 2: RETVAL = GTK_MICRO_VERSION; break;
	case 3: RETVAL = gtk_major_version; break;
	case 4: RETVAL = gtk_minor_version; break;
	case 5: RETVAL = gtk_micro_version; break;
	default:
		RETVAL = -1;
		g_assert_not_reached ();
	}
    OUTPUT:
	RETVAL

=for apidoc
=for signature (MAJOR, MINOR, MICRO) = Gtk2->GET_VERSION_INFO
Shorthand to fetch as a list the gtk+ version for which Gtk2 was compiled.
See C<Gtk2::MAJOR_VERSION>, etc.
=cut
void
GET_VERSION_INFO (class)
    PPCODE:
	EXTEND (SP, 3);
	PUSHs (sv_2mortal (newSViv (GTK_MAJOR_VERSION)));
	PUSHs (sv_2mortal (newSViv (GTK_MINOR_VERSION)));
	PUSHs (sv_2mortal (newSViv (GTK_MICRO_VERSION)));
	PERL_UNUSED_VAR (ax);

=for apidoc
Provides a mechanism for checking the version information that Gtk2 was
compiled against. Essentially equvilent to the macro GTK_CHECK_VERSION. In most
cases this function should be used rather than 
L<check_version ()|/"string = Gtk2-E<gt>B<check_version> ($required_major, $required_minor, $required_micro)">.
=cut
gboolean
CHECK_VERSION (class, guint required_major, guint required_minor, guint required_micro)
    CODE:
	RETVAL = GTK_CHECK_VERSION (required_major, required_minor,
				    required_micro);
    OUTPUT:
	RETVAL


#############################################################################
#############################################################################

=for object Gtk2::main
=cut

=for apidoc Gtk2::init_check
This is the non-fatal version of C<< Gtk2->init >>; instead of calling C<exit>
if Gtk+ initialization fails, C<< Gtk2->init_check >> returns false.  This
allows your application to fall back on some other means of communication with
the user - for example a curses or command-line interface.
=cut

=for apidoc
Initialize Gtk+.  This must be called before any other Gtk2 functions in a 
GUI application; the Gtk2 module's import method allows you to pass C<-init>
in the C<use> statement to do this automatically.  This function also scans
I<@ARGV> for any options it knows, and will remove them automagically.

Note: this function will terminate your program if it is unable to initialize
the gui for any reason.  If you want your program to fall back to some other
interface, you want to use C<< Gtk2->init_check >> instead.
=cut
gboolean
gtk_init (class=NULL)
    ALIAS:
	Gtk2::init_check = 2
    PREINIT:
	GPerlArgv *pargv;
    CODE:
	pargv = gperl_argv_new ();

	if (ix == 2) {
		RETVAL = gtk_init_check (&pargv->argc, &pargv->argv);
	} else if (PL_minus_c) {
		/* When in syntax check mode, we need to avoid calling gtk_init
		 * even if asked to because it might abort the program (e.g. if
		 * DISPLAY is not set). */
		RETVAL = gtk_init_check (&pargv->argc, &pargv->argv);



( run in 0.506 second using v1.01-cache-2.11-cpan-5511b514fd6 )