[gtk+] Turn the gtk version and age variables into functions



commit cb24bcc61301c2099289e684edb93becb2a01c39
Author: Tor Lillqvist <tml iki fi>
Date:   Wed Sep 8 17:36:10 2010 +0300

    Turn the gtk version and age variables into functions
    
    Having variables exported from a DLL is slightly painful and
    potentially error-prone on Windows, so let's try get rid of them now
    when we can. Starting with these.

 demos/gtk-demo/appwindow.c               |    6 ++-
 docs/reference/gtk/tmpl/gtkfeatures.sgml |   58 ------------------
 gtk/gtk.symbols                          |   10 ++--
 gtk/gtkmain.c                            |   97 ++++++++++++++++++++++++++++--
 gtk/gtkmain.h                            |   19 ++----
 tests/testgtk.c                          |   10 ++--
 6 files changed, 111 insertions(+), 89 deletions(-)
---
diff --git a/demos/gtk-demo/appwindow.c b/demos/gtk-demo/appwindow.c
index 57cb0ce..2953bb8 100644
--- a/demos/gtk-demo/appwindow.c
+++ b/demos/gtk-demo/appwindow.c
@@ -124,7 +124,11 @@ about_cb (GtkAction *action,
   gtk_about_dialog_set_url_hook (activate_url, NULL, NULL);
   gtk_show_about_dialog (GTK_WINDOW (window),
 			 "program-name", "GTK+ Code Demos",
-			 "version", PACKAGE_VERSION,
+			 "version", g_strdup_printf ("%s,\nRunning against GTK+ %d.%d.%d",
+						     PACKAGE_VERSION,
+						     gtk_major_version (),
+						     gtk_minor_version (),
+						     gtk_micro_version ()),
 			 "copyright", "(C) 1997-2009 The GTK+ Team",
 			 "license-type", GTK_LICENSE_LGPL_2_1,
 			 "website", "http://www.gtk.org";,
diff --git a/docs/reference/gtk/tmpl/gtkfeatures.sgml b/docs/reference/gtk/tmpl/gtkfeatures.sgml
index 16e0add..f6f7d95 100644
--- a/docs/reference/gtk/tmpl/gtkfeatures.sgml
+++ b/docs/reference/gtk/tmpl/gtkfeatures.sgml
@@ -22,64 +22,6 @@ typically use the features described here.
 <!-- ##### SECTION Image ##### -->
 
 
-<!-- ##### VARIABLE gtk_major_version ##### -->
-<para>
-The major version number of the GTK+ library.  (e.g. in GTK+ version
-1.2.5 this is 1.) 
-</para>
-
-<para>
-This variable is in the library, so represents the
-GTK+ library you have linked against. Contrast with the
-#GTK_MAJOR_VERSION macro, which represents the major version of the
-GTK+ headers you have included.
-</para>
-
-
-<!-- ##### VARIABLE gtk_minor_version ##### -->
-<para>
-The minor version number of the GTK+ library.
-(e.g. in GTK+ version 1.2.5 this is 2.)
-</para>
-
-<para>
-This variable is in the library, so represents the
-GTK+ library you have linked against. Contrast with the
-#GTK_MINOR_VERSION macro, which represents the minor version of the
-GTK+ headers you have included.
-</para>
-
-
-<!-- ##### VARIABLE gtk_micro_version ##### -->
-<para>
-The micro version number of the GTK+ library.
-(e.g. in GTK+ version 1.2.5 this is 5.)
-</para>
-
-
-<para>
-This variable is in the library, so represents the GTK+ library you
-have linked against. Contrast with the #GTK_MICRO_VERSION macro, which
-represents the micro version of the GTK+ headers you have included.
-</para>
-
-
-<!-- ##### VARIABLE gtk_binary_age ##### -->
-<para>
-This is the binary age passed to <application>libtool</application>. If 
-<application>libtool</application> means nothing to you, don't worry 
-about it. ;-)
-</para>
-
-
-<!-- ##### VARIABLE gtk_interface_age ##### -->
-<para>
-This is the interface age passed to <application>libtool</application>. If 
-<application>libtool</application> means nothing to you, don't worry 
-about it. ;-)
-</para>
-
-
 <!-- ##### FUNCTION gtk_check_version ##### -->
 <para>
 </para>
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 3ba5bb8..64792c9 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -1860,6 +1860,11 @@ gtk_events_pending
 gtk_disable_setlocale
 gtk_distribute_natural_allocation
 gtk_set_locale
+gtk_binary_age
+gtk_interface_age
+gtk_major_version
+gtk_minor_version
+gtk_micro_version
 gtk_check_version
 gtk_get_default_language
 gtk_get_event_widget
@@ -4535,11 +4540,6 @@ gtk_info_bar_get_message_type
 #endif
 
 #ifdef INCLUDE_VARIABLES
-gtk_binary_age
-gtk_interface_age
-gtk_major_version
-gtk_minor_version
-gtk_micro_version
 gtk_debug_flags
 gtk_text_attr_appearance_type
 gtk_text_char_type
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index a7cd846..89c2c30 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -179,12 +179,6 @@ static gint  gtk_invoke_key_snoopers	 (GtkWidget	     *grab_widget,
 
 static GtkWindowGroup *gtk_main_get_window_group (GtkWidget   *widget);
 
-const guint gtk_major_version = GTK_MAJOR_VERSION;
-const guint gtk_minor_version = GTK_MINOR_VERSION;
-const guint gtk_micro_version = GTK_MICRO_VERSION;
-const guint gtk_binary_age = GTK_BINARY_AGE;
-const guint gtk_interface_age = GTK_INTERFACE_AGE;
-
 static guint gtk_main_loop_level = 0;
 static gint pre_initialized = FALSE;
 static gint gtk_initialized = FALSE;
@@ -219,6 +213,97 @@ static const GDebugKey gtk_debug_keys[] = {
 #endif /* G_ENABLE_DEBUG */
 
 /**
+ * gtk_major_version:
+ *
+ * Returns the major version number of the GTK+ library.  (e.g. in GTK+ version
+ * 3.1.5 this is 3.) 
+ *
+ * This function is in the library, so it represents the GTK+ library
+ * your code is running against. Contrast with the #GTK_MAJOR_VERSION
+ * macro, which represents the major version of the GTK+ headers you
+ * have included when compiling your code.
+ *
+ * Returns the major version number of the GTK+ library.
+ */
+guint
+gtk_major_version (void)
+{
+  return GTK_MAJOR_VERSION;
+}
+
+/**
+ * gtk_minor_version:
+ *
+ * Returns the minor version number of the GTK+ library.  (e.g. in GTK+ version
+ * 3.1.5 this is 1.) 
+ *
+ * This function is in the library, so it represents the GTK+ library
+ * your code is are running against. Contrast with the
+ * #GTK_MINOR_VERSION macro, which represents the minor version of the
+ * GTK+ headers you have included when compiling your code.
+ *
+ * Returns the minor version number of the GTK+ library.
+ */
+guint
+gtk_minor_version (void)
+{
+  return GTK_MINOR_VERSION;
+}
+
+/**
+ * gtk_micro_version:
+ *
+ * Returns the micro version number of the GTK+ library.  (e.g. in GTK+ version
+ * 3.1.5 this is 5.) 
+ *
+ * This function is in the library, so it represents the GTK+ library
+ * your code is are running against. Contrast with the
+ * #GTK_MICRO_VERSION macro, which represents the micro version of the
+ * GTK+ headers you have included when compiling your code.
+ *
+ * Returns the micro version number of the GTK+ library.
+ */
+guint
+gtk_micro_version (void)
+{
+  return GTK_MICRO_VERSION;
+}
+
+/**
+ * gtk_binary_age:
+ *
+ * Returns the binary age as passed to
+ * <application>libtool</application> when building the GTK+ library
+ * the process is running against. If
+ * <application>libtool</application> means nothing to you, don't
+ * worry about it.
+ *
+ * Returns the binary age of the GTK+ library.
+ */
+guint
+gtk_binary_age (void)
+{
+  return GTK_BINARY_AGE;
+}
+
+/**
+ * gtk_interface_age:
+ *
+ * Returns the interface age as passed to
+ * <application>libtool</application> when building the GTK+ library
+ * the process is running against. If
+ * <application>libtool</application> means nothing to you, don't
+ * worry about it.
+ *
+ * Returns the interface age of the GTK+ library.
+ */
+guint
+gtk_interface_age (void)
+{
+  return GTK_INTERFACE_AGE;
+}
+
+/**
  * gtk_check_version:
  * @required_major: the required major version.
  * @required_minor: the required minor version.
diff --git a/gtk/gtkmain.h b/gtk/gtkmain.h
index fe4ff99..ca7bd66 100644
--- a/gtk/gtkmain.h
+++ b/gtk/gtkmain.h
@@ -51,21 +51,12 @@ typedef gint	(*GtkKeySnoopFunc)	    (GtkWidget	  *grab_widget,
 
 /* Gtk version.
  */
-#ifdef G_PLATFORM_WIN32
-#ifdef GTK_COMPILATION
-#define GTKMAIN_C_VAR __declspec(dllexport)
-#else
-#define GTKMAIN_C_VAR extern __declspec(dllimport)
-#endif
-#else
-#define GTKMAIN_C_VAR extern
-#endif
+guint gtk_major_version (void) G_GNUC_CONST;
+guint gtk_minor_version (void) G_GNUC_CONST;
+guint gtk_micro_version (void) G_GNUC_CONST;
+guint gtk_binary_age    (void) G_GNUC_CONST;
+guint gtk_interface_age (void) G_GNUC_CONST;
 
-GTKMAIN_C_VAR const guint gtk_major_version;
-GTKMAIN_C_VAR const guint gtk_minor_version;
-GTKMAIN_C_VAR const guint gtk_micro_version;
-GTKMAIN_C_VAR const guint gtk_binary_age;
-GTKMAIN_C_VAR const guint gtk_interface_age;
 const gchar* gtk_check_version (guint	required_major,
 			        guint	required_minor,
 			        guint	required_micro);
diff --git a/tests/testgtk.c b/tests/testgtk.c
index cddb7df..b29c4d4 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -10333,14 +10333,14 @@ create_main_window (void)
   if (gtk_micro_version > 0)
     sprintf (buffer,
 	     "Gtk+ v%d.%d.%d",
-	     gtk_major_version,
-	     gtk_minor_version,
-	     gtk_micro_version);
+	     gtk_major_version (),
+	     gtk_minor_version (),
+	     gtk_micro_version ());
   else
     sprintf (buffer,
 	     "Gtk+ v%d.%d",
-	     gtk_major_version,
-	     gtk_minor_version);
+	     gtk_major_version (),
+	     gtk_minor_version ());
 
   label = gtk_label_new (buffer);
   gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]